filebrowser/storage/bolt/bolt.go

32 lines
860 B
Go
Raw Normal View History

package bolt
import (
"github.com/asdine/storm"
2020-06-01 07:12:36 +08:00
"github.com/filebrowser/filebrowser/v2/auth"
"github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/share"
"github.com/filebrowser/filebrowser/v2/storage"
"github.com/filebrowser/filebrowser/v2/users"
)
// NewStorage creates a storage.Storage based on Bolt DB.
func NewStorage(db *storm.DB) (*storage.Storage, error) {
2020-06-01 07:12:36 +08:00
userStore := users.NewStorage(usersBackend{db: db})
shareStore := share.NewStorage(shareBackend{db: db})
settingsStore := settings.NewStorage(settingsBackend{db: db})
authStore := auth.NewStorage(authBackend{db: db}, userStore)
2021-07-26 18:00:05 +08:00
err := save(db, "version", 2) //nolint:gomnd
if err != nil {
return nil, err
}
return &storage.Storage{
2020-06-01 07:12:36 +08:00
Auth: authStore,
Users: userStore,
Share: shareStore,
Settings: settingsStore,
}, nil
}