diff options
Diffstat (limited to 'packages/meshbay-node/tests/test_indexer_silent_disk.py')
| -rw-r--r-- | packages/meshbay-node/tests/test_indexer_silent_disk.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/packages/meshbay-node/tests/test_indexer_silent_disk.py b/packages/meshbay-node/tests/test_indexer_silent_disk.py index 4073ac5..00e2728 100644 --- a/packages/meshbay-node/tests/test_indexer_silent_disk.py +++ b/packages/meshbay-node/tests/test_indexer_silent_disk.py @@ -469,14 +469,29 @@ async def test_a_scan_asks_the_disk_nothing_from_the_event_loop(tmp_path, monkey (films / "sub" / "c.mkv").write_bytes(b"c") idx = _indexer(RootSet.build([{"path": str(films)}])) asked: set[str] = set() - real = Path.stat + real_stat, real_scandir = os.stat, os.scandir + # What the root holds, not the root: its own availability check is the + # roots' I/O thread's, also off the loop. + inside = str(films) + os.sep - def stat(self, **kw): - if films in self.parents: + def note(path) -> None: + if os.fspath(path).startswith(inside): asked.add(threading.current_thread().name.split("_")[0]) - return real(self, **kw) - monkeypatch.setattr(Path, "stat", stat) + def stat(path, *a, **kw): + note(path) + return real_stat(path, *a, **kw) + + def scandir(path="."): + note(path) + return real_scandir(path) + + # os, not Path: the indexer calls os.stat(long_path(p)) and os.scandir + # since it learned Windows' long paths, and Path.stat calls os.stat too. + # Patching Path.stat saw no call at all after that change, and so watched + # nothing. + monkeypatch.setattr(os, "stat", stat) + monkeypatch.setattr(os, "scandir", scandir) await idx.initial_scan() (films / "new.mkv").write_bytes(b"missed by the watcher") await idx.reconcile() |