mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
4bc6a23143
Fixes the error where File Browser would fail when the DB existed with size 0. This closes #628.
@1138-4EB I decided not to check the version for now since it's the first time we're adding that info. Only the next time we change the DB structure we'll use that value as reference to know how to upgrade.
I did not check it because the users running rc1 would have some issues with it.
Former-commit-id: e8b07ab919e9c24feee8f6f2dd6df30df1e2325f [formerly 3396f05b4a1a07e1b993b7c07d1afd2def9cabbb] [formerly b43eb8e400603f99baf7966a58156dec7bd47420 [formerly c1c57c6525
]]
Former-commit-id: 1115d0cf8a601feafac2b33cb46b813343f4fa8c [formerly 05de6caf8cf747a95fbb10587f0a767dfb8b8774]
Former-commit-id: 840c1a278cd45d36ce8538b7c5fe97923be05ca3
31 lines
802 B
Go
31 lines
802 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) {
|
|
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
|
|
}
|