mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
40 lines
639 B
Go
40 lines
639 B
Go
package importer
|
|
|
|
import (
|
|
"github.com/asdine/storm/v3"
|
|
|
|
"github.com/filebrowser/filebrowser/v2/storage/bolt"
|
|
)
|
|
|
|
// Import imports an old configuration to a newer database.
|
|
func Import(oldDBPath, oldConf, newDBPath string) error {
|
|
oldDB, err := storm.Open(oldDBPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer oldDB.Close()
|
|
|
|
newDB, err := storm.Open(newDBPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer newDB.Close()
|
|
|
|
sto, err := bolt.NewStorage(newDB)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = importUsers(oldDB, sto)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = importConf(oldDB, oldConf, sto)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return err
|
|
}
|