Archived
We should pass around db.Instance instead of leveldb.DB
We're going to need the db.Instance to keep some state, and for that to work we need the same one passed around everywhere. Hence this moves the leveldb-specific file opening stuff into the db package and exports the dbInstance type.
This commit is contained in:
1 parent
313485e406
commit
2a4fc28318
20 files changed
+145
-241
No files matched your search
+1
-2
@@ -10,7 +10,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/db"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
)
|
||||
|
||||
type DeviceStatistics struct {
|
||||
@@ -22,7 +21,7 @@ type DeviceStatisticsReference struct {
|
||||
device string
|
||||
}
|
||||
|
||||
func NewDeviceStatisticsReference(ldb *leveldb.DB, device string) *DeviceStatisticsReference {
|
||||
func NewDeviceStatisticsReference(ldb *db.Instance, device string) *DeviceStatisticsReference {
|
||||
prefix := string(db.KeyTypeDeviceStatistic) + device
|
||||
return &DeviceStatisticsReference{
|
||||
ns: db.NewNamespacedKV(ldb, prefix),
|
||||
|
||||
+1
-2
@@ -10,7 +10,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/db"
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
)
|
||||
|
||||
type FolderStatistics struct {
|
||||
@@ -28,7 +27,7 @@ type LastFile struct {
|
||||
Deleted bool `json:"deleted"`
|
||||
}
|
||||
|
||||
func NewFolderStatisticsReference(ldb *leveldb.DB, folder string) *FolderStatisticsReference {
|
||||
func NewFolderStatisticsReference(ldb *db.Instance, folder string) *FolderStatisticsReference {
|
||||
prefix := string(db.KeyTypeFolderStatistic) + folder
|
||||
return &FolderStatisticsReference{
|
||||
ns: db.NewNamespacedKV(ldb, prefix),
|
||||
|
||||
Reference in new issue
Block a user