filebrowser/storage/bolt/importer/importer.go

40 lines
639 B
Go
Raw Normal View History

package importer
import (
"github.com/asdine/storm/v3"
2020-05-31 23:12:36 +00:00
"github.com/filebrowser/filebrowser/v2/storage/bolt"
)
// Import imports an old configuration to a newer database.
2020-05-31 23:12:36 +00:00
func Import(oldDBPath, oldConf, newDBPath string) error {
oldDB, err := storm.Open(oldDBPath)
if err != nil {
return err
}
2020-05-31 23:12:36 +00:00
defer oldDB.Close()
2020-05-31 23:12:36 +00:00
newDB, err := storm.Open(newDBPath)
if err != nil {
return err
}
2020-05-31 23:12:36 +00:00
defer newDB.Close()
2020-05-31 23:12:36 +00:00
sto, err := bolt.NewStorage(newDB)
if err != nil {
return err
}
2020-05-31 23:12:36 +00:00
err = importUsers(oldDB, sto)
if err != nil {
return err
}
2020-05-31 23:12:36 +00:00
err = importConf(oldDB, oldConf, sto)
if err != nil {
return err
}
return err
}