Skip to content

Commit

Permalink
Handle MovedFrom events
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Nov 7, 2024
1 parent 6ec9f4f commit ed8c91a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/storage/fs/posix/tree/assimilation.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const (
ActionUpdate
ActionMove
ActionDelete
ActionMoveFrom
)

type queueItem struct {
Expand Down Expand Up @@ -222,9 +223,18 @@ func (t *Tree) Scan(path string, action EventAction, isDir bool) error {
Recurse: isDir,
})

case ActionMoveFrom:
// 6. file/directory moved out of the watched directory
// -> update directory
if err := t.setDirty(filepath.Dir(path), true); err != nil {
return err
}

go func() { _ = t.WarmupIDCache(filepath.Dir(path), false, true) }()

case ActionDelete:
_ = t.HandleFileDelete(path)
// 6. Deleted file or directory
// 7. Deleted file or directory
// -> update parent and all children
if err := t.setDirty(filepath.Dir(path), true); err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions pkg/storage/fs/posix/tree/gpfswatchfolderwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (w *GpfsWatchFolderWatcher) Watch(topic string) {
case strings.Contains(lwev.Event, "IN_DELETE"):
_ = w.tree.Scan(lwev.Path, ActionDelete, isDir)

case strings.Contains(lwev.Event, "IN_MOVE_FROM"):
_ = w.tree.Scan(lwev.Path, ActionMoveFrom, isDir)

case strings.Contains(lwev.Event, "IN_CREATE"):
_ = w.tree.Scan(lwev.Path, ActionCreate, isDir)

Expand Down
3 changes: 3 additions & 0 deletions pkg/storage/fs/posix/tree/inotifywatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (iw *InotifyWatcher) Watch(path string) {
Events: []inotifywaitgo.EVENT{
inotifywaitgo.CREATE,
inotifywaitgo.MOVED_TO,
inotifywaitgo.MOVED_FROM,
inotifywaitgo.CLOSE_WRITE,
inotifywaitgo.DELETE,
},
Expand All @@ -50,6 +51,8 @@ func (iw *InotifyWatcher) Watch(path string) {
switch e {
case inotifywaitgo.DELETE:
_ = iw.tree.Scan(event.Filename, ActionDelete, event.IsDir)
case inotifywaitgo.MOVED_FROM:
_ = iw.tree.Scan(event.Filename, ActionMoveFrom, event.IsDir)
case inotifywaitgo.CREATE:
case inotifywaitgo.MOVED_TO:
_ = iw.tree.Scan(event.Filename, ActionCreate, event.IsDir)
Expand Down

0 comments on commit ed8c91a

Please sign in to comment.