atom / watcher

Atom Filesystem Watcher

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

watcher is not firing a `deleted` event when I move a file to the trash.

george-thomas-hill opened this issue · comments

Prerequisites

Description

watcher is not firing a deleted event when I move a file to the trash.

Steps to Reproduce

I am running Kubuntu 21.04 and Node.js 12.21.0.

I set up a watcher instance watching my home directory with

const myWatcher = await watcher.watchPath(directory, {}, handleEvents);

I create a file in my home directory.

When I delete the file, I get a deleted event from my watcher.

But when I move a file to the trash, I don't get any event from my watcher.

Expected behavior:

I expected to get a deleted event from my watcher.

Actual behavior:

I don't get a deleted event from my watcher.

Here's the output from my terminal:

* created: /home/georgehill/test1.txt.part
* modified: /home/georgehill/test1.txt.part
* renamed: /home/georgehill/test1.txt
  from: /home/georgehill/test1.txt.part
* deleted: /home/georgehill/test1.txt
* created: /home/georgehill/test2.txt.part
* modified: /home/georgehill/test2.txt.part
* renamed: /home/georgehill/test2.txt
  from: /home/georgehill/test2.txt.part

I created test1.txt and then deleted it.

I created test2.txt and then moved it to the trash.

You'll note that I didn't get any event about that.

(I don't get a message when I empty my trash, either.)

Reproduces how often:

This happens 100% of the time.

Versions

Kubuntu 21.04.

Node.js 12.21.0.

Additional Information

watcher is otherwise really great.

I hope that this bug can be fixed.

Thank you.

D'oh!

Never mind.

This bug report can be closed.

My JavaScript event handler was filtering out events where event.path was in a hidden directory (i.e. one where a parent folder's name started with a period).

When I move an item to the trash, I get a renamed event whose event.path is a hidden directory but whose event.oldPath is from one of my visible directories:

* created: /home/georgehill/test3.txt
* renamed: /home/georgehill/.local/share/Trash/files/test3.txt
  from: /home/georgehill/test3.txt

Everything is fine.

I apologize for the false alarm.

On macOS (and Windows when permanent deletion is turned off), "deleting" a file simply moves it to the recycle bin / trash. So the fact that you get a renamed event makes sense. You should close this issue since it's not a problem with the watcher.