MCPcopy
hub / github.com/syncthing/syncthing / emitDiskChangeEvents

Method emitDiskChangeEvents

lib/model/folder.go:1325–1355  ·  view source on GitHub ↗
(fs []protocol.FileInfo, typeOfEvent events.EventType)

Source from the content-addressed store, hash-verified

1323}
1324
1325func (f *folder) emitDiskChangeEvents(fs []protocol.FileInfo, typeOfEvent events.EventType) {
1326 for _, file := range fs {
1327 if file.IsInvalid() {
1328 continue
1329 }
1330
1331 objType := "file"
1332 action := "modified"
1333
1334 if file.IsDeleted() {
1335 action = "deleted"
1336 }
1337
1338 if file.IsSymlink() {
1339 objType = "symlink"
1340 } else if file.IsDirectory() {
1341 objType = "dir"
1342 }
1343
1344 // Two different events can be fired here based on what EventType is passed into function
1345 f.evLogger.Log(typeOfEvent, map[string]string{
1346 "folder": f.ID,
1347 "folderID": f.ID, // incorrect, deprecated, kept for historical compliance
1348 "label": f.Label,
1349 "action": action,
1350 "type": objType,
1351 "path": filepath.FromSlash(file.Name),
1352 "modifiedBy": file.ModifiedBy.String(),
1353 })
1354 }
1355}
1356
1357func (f *folder) handleForcedRescans(ctx context.Context) error {
1358 f.forcedRescanPathsMut.Lock()

Callers 2

Calls 6

IsDeletedMethod · 0.80
IsSymlinkMethod · 0.65
LogMethod · 0.65
StringMethod · 0.65
IsInvalidMethod · 0.45
IsDirectoryMethod · 0.45

Tested by

no test coverage detected