MCPcopy
hub / github.com/syncthing/syncthing / updateLocals

Method updateLocals

lib/model/folder.go:1293–1323  ·  view source on GitHub ↗
(fs []protocol.FileInfo)

Source from the content-addressed store, hash-verified

1291}
1292
1293func (f *folder) updateLocals(fs []protocol.FileInfo) error {
1294 var opts []db.UpdateOption
1295 if !f.BlockIndexing {
1296 opts = append(opts, db.WithSkipBlockIndex())
1297 }
1298 if err := f.db.Update(f.folderID, protocol.LocalDeviceID, fs, opts...); err != nil {
1299 return err
1300 }
1301
1302 filenames := make([]string, len(fs))
1303 f.forcedRescanPathsMut.Lock()
1304 for i, file := range fs {
1305 filenames[i] = file.Name
1306 // No need to rescan a file that was changed since anyway.
1307 delete(f.forcedRescanPaths, file.Name)
1308 }
1309 f.forcedRescanPathsMut.Unlock()
1310
1311 seq, err := f.db.GetDeviceSequence(f.folderID, protocol.LocalDeviceID)
1312 if err != nil {
1313 return err
1314 }
1315 f.evLogger.Log(events.LocalIndexUpdated, map[string]interface{}{
1316 "folder": f.ID,
1317 "items": len(fs),
1318 "filenames": filenames,
1319 "sequence": seq,
1320 "version": seq, // legacy for sequence
1321 })
1322 return nil
1323}
1324
1325func (f *folder) emitDiskChangeEvents(fs []protocol.FileInfo, typeOfEvent events.EventType) {
1326 for _, file := range fs {

Callers 3

TestIssue4841Function · 0.80

Calls 5

WithSkipBlockIndexFunction · 0.92
UnlockMethod · 0.80
UpdateMethod · 0.65
GetDeviceSequenceMethod · 0.65
LogMethod · 0.65

Tested by 1

TestIssue4841Function · 0.64