filebrowser/storage/bolt/importer/importer.go
2019-01-05 22:44:33 +00:00

36 lines
567 B
Go

package importer
import (
"github.com/asdine/storm"
"github.com/filebrowser/filebrowser/v2/storage/bolt"
)
// Import imports an old configuration to a newer database.
func Import(oldDB, oldConf, newDB string) error {
old, err := storm.Open(oldDB)
if err != nil {
return err
}
defer old.Close()
new, err := storm.Open(newDB)
if err != nil {
return err
}
defer new.Close()
sto := bolt.NewStorage(new)
err = importUsers(old, sto)
if err != nil {
return err
}
err = importConf(old, oldConf, sto)
if err != nil {
return err
}
return err
}