Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On linux with python lib, rename events seems not associate path correctly when moving accross folders #65

Closed
yufei-pan opened this issue Jan 29, 2025 · 2 comments

Comments

@yufei-pan
Copy link

mv tf/t1 ./t0

{"effect_time":1738138917604701582,"path_name":".../test/tf/t1","associated_path_name":".../test/tf/t0","effect_type":"rename","path_type":"file"}

while the associated path should be .../test/t0

This also happens when trying to move files inside

@e-dant
Copy link
Owner

e-dant commented Feb 1, 2025

This is strictly an issue with inotify.

The bug is that we weren't checking what (path, watch-descriptor) pair the event is associated with.

Per the kernel: https://github.com/torvalds/linux/blob/cabb4685d57ed50cd197498d2ac946ad5b6272e7/include/uapi/linux/inotify.h#L15-L27

@e-dant
Copy link
Owner

e-dant commented Feb 1, 2025

Should be fixed in: 4d8f978

More documentation on the fix here: 691729b

Some testing here:

$ tool/hone && tool/build --no-run && rm -rf /tmp/wtr && mkdir /tmp/wtr && ( out/this/Release/wtr.watcher /tmp/wtr -ms 1000 | jq '. | select(.associated)' ) & ( cd /tmp/wtr ; sleep 0.1 ; mkdir a ; touch a/b ; mv a/b b ; )
{
  "path_type": "file",
  "path_name": "/tmp/wtr/a/b",
  "effect_type": "rename",
  "effect_time": 1738450318057588500,
  "associated": {
    "path_type": "file",
    "path_name": "/tmp/wtr/b",
    "effect_type": "rename",
    "effect_time": 1738450318057587200,
    "associated": null
  }
}

@e-dant e-dant closed this as completed Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants