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

Undo from finder/explorer does not report file events #185

Open
bpasero opened this issue Aug 28, 2024 · 2 comments
Open

Undo from finder/explorer does not report file events #185

bpasero opened this issue Aug 28, 2024 · 2 comments

Comments

@bpasero
Copy link
Contributor

bpasero commented Aug 28, 2024

Steps:

  • setup parcel watcher according to docs, simply watching a folder [1]
  • create a sub-folder in that watched folder
  • create a file in that sub-folder
  • from the finder (macOS) or explorer (Windows) delete the sub-folder
  • => you get a delete event for that folder
  • undo the operation from the finder / explorer
  • => you get a create event but only for the folder, not for the files within

[1]

const watcher = require('@parcel/watcher');
const path = require('path');

async function main() {
    // Subscribe to events
    let subscription = await watcher.subscribe(process.cwd(), (err, events) => {
        console.log(events);
    });

   
}

main();
@devongovett
Copy link
Member

I think that's because when you delete a file, it only moves it to the trash. Then when you undo, it moves it back. So actually macOS delivers a rename event in that case. Not sure there's anything we could do about that short of traversing the entire directory ourselves. But you could also do that in user land - whenever a directory is created assume it might contain children. Do any other watcher libraries handle this?

@bpasero
Copy link
Contributor Author

bpasero commented Aug 31, 2024

Maybe rename events could be emitted by parcel watcher in case the underlying OS library supports it?

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