lib/model, lib/stats: Keep track of folder's last scan time (ref #3143)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3250 LGTM: calmh, AudriusButkevicius
This commit is contained in:
committed by
Audrius Butkevicius
parent
16063933d1
commit
48245effdf
@@ -13,7 +13,8 @@ import (
|
||||
)
|
||||
|
||||
type FolderStatistics struct {
|
||||
LastFile LastFile `json:"lastFile"`
|
||||
LastFile LastFile `json:"lastFile"`
|
||||
LastScan time.Time `json:"lastScan"`
|
||||
}
|
||||
|
||||
type FolderStatisticsReference struct {
|
||||
@@ -59,8 +60,21 @@ func (s *FolderStatisticsReference) ReceivedFile(file string, deleted bool) {
|
||||
s.ns.PutBool("lastFileDeleted", deleted)
|
||||
}
|
||||
|
||||
func (s *FolderStatisticsReference) ScanCompleted() {
|
||||
s.ns.PutTime("lastScan", time.Now())
|
||||
}
|
||||
|
||||
func (s *FolderStatisticsReference) GetLastScanTime() time.Time {
|
||||
lastScan, ok := s.ns.Time("lastScan")
|
||||
if !ok {
|
||||
return time.Time{}
|
||||
}
|
||||
return lastScan
|
||||
}
|
||||
|
||||
func (s *FolderStatisticsReference) GetStatistics() FolderStatistics {
|
||||
return FolderStatistics{
|
||||
LastFile: s.GetLastFile(),
|
||||
LastScan: s.GetLastScanTime(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user