2019-01-05 22:44:33 +00:00
|
|
|
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()
|
|
|
|
|
2019-01-09 21:37:47 +00:00
|
|
|
sto, err := bolt.NewStorage(new)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-01-05 22:44:33 +00:00
|
|
|
|
|
|
|
err = importUsers(old, sto)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = importConf(old, oldConf, sto)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|