2019-01-06 06:44:33 +08:00
|
|
|
package bolt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/asdine/storm"
|
|
|
|
"github.com/filebrowser/filebrowser/v2/auth"
|
2019-01-06 07:01:16 +08:00
|
|
|
"github.com/filebrowser/filebrowser/v2/settings"
|
2019-01-06 06:44:33 +08: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-10 05:37:47 +08:00
|
|
|
func NewStorage(db *storm.DB) (*storage.Storage, error) {
|
2019-01-06 06:44:33 +08:00
|
|
|
users := users.NewStorage(usersBackend{db: db})
|
|
|
|
share := share.NewStorage(shareBackend{db: db})
|
2019-01-06 07:01:16 +08:00
|
|
|
settings := settings.NewStorage(settingsBackend{db: db})
|
2019-01-06 06:44:33 +08:00
|
|
|
auth := auth.NewStorage(authBackend{db: db}, users)
|
|
|
|
|
2019-01-10 05:37:47 +08:00
|
|
|
err := save(db, "version", 2)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-01-06 06:44:33 +08:00
|
|
|
return &storage.Storage{
|
2019-01-06 07:01:16 +08:00
|
|
|
Auth: auth,
|
|
|
|
Users: users,
|
|
|
|
Share: share,
|
2019-01-06 06:44:33 +08:00
|
|
|
Settings: settings,
|
2019-01-10 05:37:47 +08:00
|
|
|
}, nil
|
2019-01-06 06:44:33 +08:00
|
|
|
}
|