mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
32 lines
845 B
Go
32 lines
845 B
Go
package bolt
|
|
|
|
import (
|
|
"github.com/asdine/storm"
|
|
|
|
"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) {
|
|
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)
|
|
|
|
err := save(db, "version", 2)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &storage.Storage{
|
|
Auth: authStore,
|
|
Users: userStore,
|
|
Share: shareStore,
|
|
Settings: settingsStore,
|
|
}, nil
|
|
}
|