mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
c1c57c6525
Fixes the error where File Browser would fail when the DB existed with size 0. This closes #628. @1138-4EB I decided not to check the version for now since it's the first time we're adding that info. Only the next time we change the DB structure we'll use that value as reference to know how to upgrade. I did not check it because the users running rc1 would have some issues with it.
39 lines
605 B
Go
39 lines
605 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, err := bolt.NewStorage(new)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = importUsers(old, sto)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = importConf(old, oldConf, sto)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return err
|
|
}
|