mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
Generate events on scanning updates
This commit is contained in:
parent
e27d42935c
commit
ee005fbc8e
@ -764,6 +764,13 @@ func (m *Model) ScanRepo(repo string) error {
|
|||||||
batchSize := 100
|
batchSize := 100
|
||||||
batch := make([]protocol.FileInfo, 0, 00)
|
batch := make([]protocol.FileInfo, 0, 00)
|
||||||
for f := range fchan {
|
for f := range fchan {
|
||||||
|
events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{
|
||||||
|
"repo": repo,
|
||||||
|
"name": f.Name,
|
||||||
|
"modified": time.Unix(f.Modified, 0),
|
||||||
|
"flags": fmt.Sprintf("0%o", f.Flags),
|
||||||
|
"size": f.Size(),
|
||||||
|
})
|
||||||
if len(batch) == batchSize {
|
if len(batch) == batchSize {
|
||||||
fs.Update(protocol.LocalNodeID, batch)
|
fs.Update(protocol.LocalNodeID, batch)
|
||||||
batch = batch[:0]
|
batch = batch[:0]
|
||||||
@ -787,6 +794,13 @@ func (m *Model) ScanRepo(repo string) error {
|
|||||||
f.Flags |= protocol.FlagDeleted
|
f.Flags |= protocol.FlagDeleted
|
||||||
f.Version = lamport.Default.Tick(f.Version)
|
f.Version = lamport.Default.Tick(f.Version)
|
||||||
f.LocalVersion = 0
|
f.LocalVersion = 0
|
||||||
|
events.Default.Log(events.LocalIndexUpdated, map[string]interface{}{
|
||||||
|
"repo": repo,
|
||||||
|
"name": f.Name,
|
||||||
|
"modified": time.Unix(f.Modified, 0),
|
||||||
|
"flags": fmt.Sprintf("0%o", f.Flags),
|
||||||
|
"size": f.Size(),
|
||||||
|
})
|
||||||
batch = append(batch, f)
|
batch = append(batch, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,9 +167,6 @@ func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo, ign map[string][
|
|||||||
cf := w.CurrentFiler.CurrentFile(rn)
|
cf := w.CurrentFiler.CurrentFile(rn)
|
||||||
permUnchanged := w.IgnorePerms || !protocol.HasPermissionBits(cf.Flags) || PermsEqual(cf.Flags, uint32(info.Mode()))
|
permUnchanged := w.IgnorePerms || !protocol.HasPermissionBits(cf.Flags) || PermsEqual(cf.Flags, uint32(info.Mode()))
|
||||||
if !protocol.IsDeleted(cf.Flags) && protocol.IsDirectory(cf.Flags) && permUnchanged {
|
if !protocol.IsDeleted(cf.Flags) && protocol.IsDirectory(cf.Flags) && permUnchanged {
|
||||||
if debug {
|
|
||||||
l.Debugln("unchanged:", cf)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,9 +195,6 @@ func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo, ign map[string][
|
|||||||
cf := w.CurrentFiler.CurrentFile(rn)
|
cf := w.CurrentFiler.CurrentFile(rn)
|
||||||
permUnchanged := w.IgnorePerms || !protocol.HasPermissionBits(cf.Flags) || PermsEqual(cf.Flags, uint32(info.Mode()))
|
permUnchanged := w.IgnorePerms || !protocol.HasPermissionBits(cf.Flags) || PermsEqual(cf.Flags, uint32(info.Mode()))
|
||||||
if !protocol.IsDeleted(cf.Flags) && cf.Modified == info.ModTime().Unix() && permUnchanged {
|
if !protocol.IsDeleted(cf.Flags) && cf.Modified == info.ModTime().Unix() && permUnchanged {
|
||||||
if debug {
|
|
||||||
l.Debugln("unchanged:", cf)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user