mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
lib/stats need not depend on protocol
This commit is contained in:
parent
37ed5a01e0
commit
06f319a380
@ -1003,7 +1003,7 @@ func (m *Model) deviceStatRef(deviceID protocol.DeviceID) *stats.DeviceStatistic
|
|||||||
return sr
|
return sr
|
||||||
}
|
}
|
||||||
|
|
||||||
sr := stats.NewDeviceStatisticsReference(m.db, deviceID)
|
sr := stats.NewDeviceStatisticsReference(m.db, deviceID.String())
|
||||||
m.deviceStatRefs[deviceID] = sr
|
m.deviceStatRefs[deviceID] = sr
|
||||||
return sr
|
return sr
|
||||||
}
|
}
|
||||||
@ -1025,7 +1025,7 @@ func (m *Model) folderStatRef(folder string) *stats.FolderStatisticsReference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) receivedFile(folder string, file protocol.FileInfo) {
|
func (m *Model) receivedFile(folder string, file protocol.FileInfo) {
|
||||||
m.folderStatRef(folder).ReceivedFile(file)
|
m.folderStatRef(folder).ReceivedFile(file.Name, file.IsDeleted())
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendIndexes(conn protocol.Connection, folder string, fs *db.FileSet, ignores *ignore.Matcher) {
|
func sendIndexes(conn protocol.Connection, folder string, fs *db.FileSet, ignores *ignore.Matcher) {
|
||||||
|
@ -9,7 +9,6 @@ package stats
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/syncthing/protocol"
|
|
||||||
"github.com/syncthing/syncthing/lib/db"
|
"github.com/syncthing/syncthing/lib/db"
|
||||||
"github.com/syndtr/goleveldb/leveldb"
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
)
|
)
|
||||||
@ -20,11 +19,11 @@ type DeviceStatistics struct {
|
|||||||
|
|
||||||
type DeviceStatisticsReference struct {
|
type DeviceStatisticsReference struct {
|
||||||
ns *db.NamespacedKV
|
ns *db.NamespacedKV
|
||||||
device protocol.DeviceID
|
device string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDeviceStatisticsReference(ldb *leveldb.DB, device protocol.DeviceID) *DeviceStatisticsReference {
|
func NewDeviceStatisticsReference(ldb *leveldb.DB, device string) *DeviceStatisticsReference {
|
||||||
prefix := string(db.KeyTypeDeviceStatistic) + device.String()
|
prefix := string(db.KeyTypeDeviceStatistic) + device
|
||||||
return &DeviceStatisticsReference{
|
return &DeviceStatisticsReference{
|
||||||
ns: db.NewNamespacedKV(ldb, prefix),
|
ns: db.NewNamespacedKV(ldb, prefix),
|
||||||
device: device,
|
device: device,
|
||||||
|
@ -9,8 +9,6 @@ package stats
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/syncthing/protocol"
|
|
||||||
|
|
||||||
"github.com/syncthing/syncthing/lib/db"
|
"github.com/syncthing/syncthing/lib/db"
|
||||||
"github.com/syndtr/goleveldb/leveldb"
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
)
|
)
|
||||||
@ -55,13 +53,13 @@ func (s *FolderStatisticsReference) GetLastFile() LastFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FolderStatisticsReference) ReceivedFile(file protocol.FileInfo) {
|
func (s *FolderStatisticsReference) ReceivedFile(file string, deleted bool) {
|
||||||
if debug {
|
if debug {
|
||||||
l.Debugln("stats.FolderStatisticsReference.ReceivedFile:", s.folder, file)
|
l.Debugln("stats.FolderStatisticsReference.ReceivedFile:", s.folder, file)
|
||||||
}
|
}
|
||||||
s.ns.PutTime("lastFileAt", time.Now())
|
s.ns.PutTime("lastFileAt", time.Now())
|
||||||
s.ns.PutString("lastFileName", file.Name)
|
s.ns.PutString("lastFileName", file)
|
||||||
s.ns.PutBool("lastFileDeleted", file.IsDeleted())
|
s.ns.PutBool("lastFileDeleted", deleted)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FolderStatisticsReference) GetStatistics() FolderStatistics {
|
func (s *FolderStatisticsReference) GetStatistics() FolderStatistics {
|
||||||
|
Loading…
Reference in New Issue
Block a user