Skip to content

Improved "rename" support #26

@aktau

Description

@aktau

As mentioned here: howeyc/fsnotify#104

Currently, it's not straightforward to detect a rename correctly. In most cases, one will see this:

RENAME file1
CREATE file2

Yet this doesn't guarantee that file1 and file2 are the same file (there could be a file creation in between, or file1 could be moved outside a watched folder and file2 could be moved in). To work around this, one could store the os.FileInfo for every watched file and use os.SameFile to compare it with the new file. This is a bit cumbersome though, as it requires keeping a lot of os.FileInfo structs in memory + bookkeeping them.

However, some platforms provide a way to atomically see what was the old name and what's the new name of a file. To quote @nathany:

On Linux there is a "cookie" used to tie the RENAME FROM and TO events together, but this isn't currently exposed by fsnotify. I still need to do more research across each platform.

This is a tracker issue to see if there is sufficient cross-platform support to enable this in the default API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions