From 6d84443db83f671272022363e2877c1b6036a0eb Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 17 Apr 2015 14:00:56 +0900 Subject: [PATCH] Homogenize the LocalIndexUpdated event It had two different formats, and we use "items" instead of "numFiles" in other places. (Discovered while documenting :) --- internal/model/model.go | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/internal/model/model.go b/internal/model/model.go index 40ba0053..f5b97b17 100644 --- a/internal/model/model.go +++ b/internal/model/model.go @@ -1035,8 +1035,8 @@ func (m *Model) updateLocals(folder string, fs []protocol.FileInfo) { m.fmut.RUnlock() events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{ - "folder": folder, - "numFiles": len(fs), + "folder": folder, + "items": len(fs), }) } @@ -1197,19 +1197,12 @@ nextSub: batchSize := 100 batch := make([]protocol.FileInfo, 0, batchSize) for f := range fchan { - events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{ - "folder": folder, - "name": f.Name, - "modified": time.Unix(f.Modified, 0), - "flags": fmt.Sprintf("0%o", f.Flags), - "size": f.Size(), - }) if len(batch) == batchSize { if err := m.CheckFolderHealth(folder); err != nil { l.Infof("Stopping folder %s mid-scan due to folder error: %s", folder, err) return err } - fs.Update(protocol.LocalDeviceID, batch) + m.updateLocals(folder, batch) batch = batch[:0] } batch = append(batch, f) @@ -1248,7 +1241,7 @@ nextSub: } if len(batch) == batchSize { - fs.Update(protocol.LocalDeviceID, batch) + m.updateLocals(folder, batch) batch = batch[:0] } @@ -1263,13 +1256,6 @@ nextSub: Modified: f.Modified, Version: f.Version, // The file is still the same, so don't bump version } - events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{ - "folder": folder, - "name": f.Name, - "modified": time.Unix(f.Modified, 0), - "flags": fmt.Sprintf("0%o", f.Flags), - "size": f.Size(), - }) batch = append(batch, nf) } else if _, err := osutil.Lstat(filepath.Join(folderCfg.Path(), f.Name)); err != nil { // File has been deleted. @@ -1287,20 +1273,13 @@ nextSub: Modified: f.Modified, Version: f.Version.Update(m.shortID), } - events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{ - "folder": folder, - "name": f.Name, - "modified": time.Unix(f.Modified, 0), - "flags": fmt.Sprintf("0%o", f.Flags), - "size": f.Size(), - }) batch = append(batch, nf) } } return true }) if len(batch) > 0 { - fs.Update(protocol.LocalDeviceID, batch) + m.updateLocals(folder, batch) } runner.setState(FolderIdle)