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:
Majed Abdulaziz
2016-06-02 19:26:52 +00:00
committed by Audrius Butkevicius
parent 16063933d1
commit 48245effdf
4 changed files with 32 additions and 1 deletions

View File

@@ -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(),
}
}