2019-01-05 22:44:33 +00:00
|
|
|
package bolt
|
|
|
|
|
|
|
|
import (
|
2022-05-03 20:48:45 +00:00
|
|
|
"github.com/asdine/storm/v3"
|
2020-05-31 23:12:36 +00:00
|
|
|
|
2019-01-05 22:44:33 +00:00
|
|
|
"github.com/filebrowser/filebrowser/v2/auth"
|
2019-01-05 23:01:16 +00:00
|
|
|
"github.com/filebrowser/filebrowser/v2/settings"
|
2019-01-05 22:44:33 +00:00
|
|
|
"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.
|
2019-01-09 21:37:47 +00:00
|
|
|
func NewStorage(db *storm.DB) (*storage.Storage, error) {
|
2020-05-31 23:12:36 +00: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)
|
2019-01-05 22:44:33 +00:00
|
|
|
|
2024-04-01 16:24:06 +00:00
|
|
|
err := save(db, "version", 2)
|
2019-01-09 21:37:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-01-05 22:44:33 +00:00
|
|
|
return &storage.Storage{
|
2020-05-31 23:12:36 +00:00
|
|
|
Auth: authStore,
|
|
|
|
Users: userStore,
|
|
|
|
Share: shareStore,
|
|
|
|
Settings: settingsStore,
|
2019-01-09 21:37:47 +00:00
|
|
|
}, nil
|
2019-01-05 22:44:33 +00:00
|
|
|
}
|