Fix ui, hide report date
This commit is contained in:
+1
-1
@@ -386,7 +386,7 @@ func (f *folder) scanSubdirs(subDirs []string) error {
|
||||
// and it's ok to release twice.
|
||||
defer snap.Release()
|
||||
|
||||
// Clean the list of subitems to ensure that we start at a known
|
||||
// ClearForVersion the list of subitems to ensure that we start at a known
|
||||
// directory, and don't scan subdirectories of things we've already
|
||||
// scanned.
|
||||
subDirs = unifySubs(subDirs, func(file string) bool {
|
||||
|
||||
+31
-32
@@ -34,6 +34,7 @@ import (
|
||||
"github.com/syncthing/syncthing/lib/scanner"
|
||||
"github.com/syncthing/syncthing/lib/stats"
|
||||
"github.com/syncthing/syncthing/lib/sync"
|
||||
"github.com/syncthing/syncthing/lib/ur/contract"
|
||||
"github.com/syncthing/syncthing/lib/util"
|
||||
"github.com/syncthing/syncthing/lib/versioner"
|
||||
)
|
||||
@@ -101,7 +102,7 @@ type Model interface {
|
||||
ConnectionStats() map[string]interface{}
|
||||
DeviceStatistics() (map[string]stats.DeviceStatistics, error)
|
||||
FolderStatistics() (map[string]stats.FolderStatistics, error)
|
||||
UsageReportingStats(version int, preview bool) map[string]interface{}
|
||||
UsageReportingStats(report *contract.Report, version int, preview bool)
|
||||
|
||||
StartDeadlockDetector(timeout time.Duration)
|
||||
GlobalDirectoryTree(folder, prefix string, levels int, dirsonly bool) map[string]interface{}
|
||||
@@ -443,7 +444,7 @@ func (m *model) stopFolder(cfg config.FolderConfiguration, err error) {
|
||||
|
||||
// Need to hold lock on m.fmut when calling this.
|
||||
func (m *model) cleanupFolderLocked(cfg config.FolderConfiguration) {
|
||||
// Clean up our config maps
|
||||
// clear up our config maps
|
||||
delete(m.folderCfgs, cfg.ID)
|
||||
delete(m.folderFiles, cfg.ID)
|
||||
delete(m.folderIgnores, cfg.ID)
|
||||
@@ -517,49 +518,49 @@ func (m *model) newFolder(cfg config.FolderConfiguration) {
|
||||
m.addAndStartFolderLocked(cfg, fset)
|
||||
}
|
||||
|
||||
func (m *model) UsageReportingStats(version int, preview bool) map[string]interface{} {
|
||||
stats := make(map[string]interface{})
|
||||
func (m *model) UsageReportingStats(report *contract.Report, version int, preview bool) {
|
||||
if version >= 3 {
|
||||
// Block stats
|
||||
blockStatsMut.Lock()
|
||||
copyBlockStats := make(map[string]int)
|
||||
for k, v := range blockStats {
|
||||
copyBlockStats[k] = v
|
||||
switch k {
|
||||
case "total":
|
||||
report.BlockStats.Total = v
|
||||
case "renamed":
|
||||
report.BlockStats.Renamed = v
|
||||
case "reused":
|
||||
report.BlockStats.Reused = v
|
||||
case "pulled":
|
||||
report.BlockStats.Pulled = v
|
||||
case "copyOrigin":
|
||||
report.BlockStats.CopyOrigin = v
|
||||
case "copyOriginShifted":
|
||||
report.BlockStats.CopyOriginShifted = v
|
||||
case "copyElsewhere":
|
||||
report.BlockStats.CopyElsewhere = v
|
||||
}
|
||||
// Reset counts, as these are incremental
|
||||
if !preview {
|
||||
blockStats[k] = 0
|
||||
}
|
||||
}
|
||||
blockStatsMut.Unlock()
|
||||
stats["blockStats"] = copyBlockStats
|
||||
|
||||
// Transport stats
|
||||
m.pmut.RLock()
|
||||
transportStats := make(map[string]int)
|
||||
for _, conn := range m.conn {
|
||||
transportStats[conn.Transport()]++
|
||||
report.TransportStats[conn.Transport()]++
|
||||
}
|
||||
m.pmut.RUnlock()
|
||||
stats["transportStats"] = transportStats
|
||||
|
||||
// Ignore stats
|
||||
ignoreStats := map[string]int{
|
||||
"lines": 0,
|
||||
"inverts": 0,
|
||||
"folded": 0,
|
||||
"deletable": 0,
|
||||
"rooted": 0,
|
||||
"includes": 0,
|
||||
"escapedIncludes": 0,
|
||||
"doubleStars": 0,
|
||||
"stars": 0,
|
||||
}
|
||||
var seenPrefix [3]bool
|
||||
for folder := range m.cfg.Folders() {
|
||||
lines, _, err := m.GetIgnores(folder)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
ignoreStats["lines"] += len(lines)
|
||||
report.IgnoreStats.Lines += len(lines)
|
||||
|
||||
for _, line := range lines {
|
||||
// Allow prefixes to be specified in any order, but only once.
|
||||
@@ -567,15 +568,15 @@ func (m *model) UsageReportingStats(version int, preview bool) map[string]interf
|
||||
if strings.HasPrefix(line, "!") && !seenPrefix[0] {
|
||||
seenPrefix[0] = true
|
||||
line = line[1:]
|
||||
ignoreStats["inverts"] += 1
|
||||
report.IgnoreStats.Inverts++
|
||||
} else if strings.HasPrefix(line, "(?i)") && !seenPrefix[1] {
|
||||
seenPrefix[1] = true
|
||||
line = line[4:]
|
||||
ignoreStats["folded"] += 1
|
||||
report.IgnoreStats.Folded++
|
||||
} else if strings.HasPrefix(line, "(?d)") && !seenPrefix[2] {
|
||||
seenPrefix[2] = true
|
||||
line = line[4:]
|
||||
ignoreStats["deletable"] += 1
|
||||
report.IgnoreStats.Deletable++
|
||||
} else {
|
||||
seenPrefix[0] = false
|
||||
seenPrefix[1] = false
|
||||
@@ -589,28 +590,26 @@ func (m *model) UsageReportingStats(version int, preview bool) map[string]interf
|
||||
line = strings.TrimPrefix(line, "**/")
|
||||
|
||||
if strings.HasPrefix(line, "/") {
|
||||
ignoreStats["rooted"] += 1
|
||||
report.IgnoreStats.Rooted++
|
||||
} else if strings.HasPrefix(line, "#include ") {
|
||||
ignoreStats["includes"] += 1
|
||||
report.IgnoreStats.Includes++
|
||||
if strings.Contains(line, "..") {
|
||||
ignoreStats["escapedIncludes"] += 1
|
||||
report.IgnoreStats.EscapedIncludes++
|
||||
}
|
||||
}
|
||||
|
||||
if strings.Contains(line, "**") {
|
||||
ignoreStats["doubleStars"] += 1
|
||||
report.IgnoreStats.DoubleStars++
|
||||
// Remove not to trip up star checks.
|
||||
line = strings.Replace(line, "**", "", -1)
|
||||
}
|
||||
|
||||
if strings.Contains(line, "*") {
|
||||
ignoreStats["stars"] += 1
|
||||
report.IgnoreStats.Stars++
|
||||
}
|
||||
}
|
||||
}
|
||||
stats["ignoreStats"] = ignoreStats
|
||||
}
|
||||
return stats
|
||||
}
|
||||
|
||||
type ConnectionInfo struct {
|
||||
|
||||
@@ -179,7 +179,7 @@ func (t *ProgressEmitter) computeProgressUpdates() []progressUpdate {
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up sentDownloadStates for devices which we are no longer connected to.
|
||||
// ClearForVersion up sentDownloadStates for devices which we are no longer connected to.
|
||||
for id := range t.sentDownloadStates {
|
||||
_, ok := t.connections[id]
|
||||
if !ok {
|
||||
|
||||
@@ -415,8 +415,8 @@ func TestSendDownloadProgressMessages(t *testing.T) {
|
||||
expectEmpty()
|
||||
|
||||
// Device is no longer subscribed to a particular folder
|
||||
delete(p.registry["folder"], "1") // Clean up first
|
||||
delete(p.registry["folder2"], "2") // Clean up first
|
||||
delete(p.registry["folder"], "1") // ClearForVersion up first
|
||||
delete(p.registry["folder2"], "2") // ClearForVersion up first
|
||||
|
||||
sendMsgs(p)
|
||||
expect(-1, state1, protocol.UpdateTypeForget, v1, nil, true)
|
||||
|
||||
@@ -79,7 +79,7 @@ func (s *sentFolderDownloadState) update(pullers []*sharedPullerState) []protoco
|
||||
|
||||
if !pullerVersion.Equal(localFile.version) || !pullerCreated.Equal(localFile.created) {
|
||||
// The version has changed or the puller was reconstrcuted due to failure.
|
||||
// Clean up whatever we had for the old file, and advertise the new file.
|
||||
// ClearForVersion up whatever we had for the old file, and advertise the new file.
|
||||
updates = append(updates, protocol.FileDownloadProgressUpdate{
|
||||
Name: name,
|
||||
Version: localFile.version,
|
||||
|
||||
Reference in New Issue
Block a user