filebrowser/storage/bolt/bolt.go

31 lines
802 B
Go
Raw Normal View History

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) {
users := users.NewStorage(usersBackend{db: db})
share := share.NewStorage(shareBackend{db: db})
settings := settings.NewStorage(settingsBackend{db: db})
auth := auth.NewStorage(authBackend{db: db}, users)
err := save(db, "version", 2)
if err != nil {
return nil, err
}
return &storage.Storage{
Auth: auth,
Users: users,
Share: share,
Settings: settings,
}, nil
}