diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-07 21:25:47 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-07 22:22:51 +0200 |
| commit | 92e25ffcc5edf5d1a9996bfb921b5a95b826134b (patch) | |
| tree | a95344747b8c43383f0078f1e6ac002bccb78c24 /packages/meshbay-node | |
| parent | 519c47841787ed7a29140df2dfb9c48b47cc414e (diff) | |
| download | meshbay-92e25ffcc5edf5d1a9996bfb921b5a95b826134b.tar.gz | |
fix(node): drop a directory moved out of the root on Windows too
On Windows watchdog cannot tell what a deleted path was -- it is gone -- and
reports a directory moved out of the root as a file deleted, so the fix in
3d5a168 never ran there and test_the_watcher_reports_a_directory_moved_out
failed. A deleted path the index still holds entries below was a directory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/indexer/indexer.py | 6 | ||||
| -rw-r--r-- | packages/meshbay-node/tests/test_root_availability.py | 13 |
2 files changed, 19 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/indexer/indexer.py b/packages/meshbay-node/src/meshbay_node/indexer/indexer.py index 732b499..f06d30f 100644 --- a/packages/meshbay-node/src/meshbay_node/indexer/indexer.py +++ b/packages/meshbay-node/src/meshbay_node/indexer/indexer.py @@ -1274,6 +1274,12 @@ class DirectoryIndexer: if not root.available: return + # On Windows watchdog cannot tell what a deleted path was -- it is + # gone -- and reports a directory moved out as a *file* deleted. + # A path the index still holds entries below was a directory. + if not directory and deleted and self._entries_in_dir(root, file_path): + directory = True + if directory: if file_path == root.path or not await off_disk( self.roots, self._dir_left_the_root, file_path): diff --git a/packages/meshbay-node/tests/test_root_availability.py b/packages/meshbay-node/tests/test_root_availability.py index e92ec95..7cc890f 100644 --- a/packages/meshbay-node/tests/test_root_availability.py +++ b/packages/meshbay-node/tests/test_root_availability.py @@ -337,6 +337,19 @@ async def test_a_directory_moved_out_of_a_live_root_is_removed(tmp_path): assert _names(idx) == {"e1.hd.mkv"} +async def test_a_directory_reported_as_a_deleted_file_is_removed(tmp_path): + """What watchdog emits on Windows: the path is gone, so it cannot say it + was a directory, and a move out of the root arrives as a file deleted.""" + shows = tmp_path / "Shows" + season = _season(shows, "S1", "e1.mp4", "e2.mp4") + _season(shows, "S2", "e3.mp4") + idx = await _indexer(_roots(shows)) + + os.rename(season, tmp_path / "S1") + await idx._update_entry(season, deleted=True, directory=False) + assert _names(idx) == {"e3.mp4"} + + async def test_a_directory_event_from_a_vanished_root_freezes(tmp_path): shows = tmp_path / "Shows" season = _season(shows, "S1", "e1.mp4", "e2.mp4") |