From a9ae496fb4e83b36d88ce98cb507871d1082b476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Wed, 22 Nov 2017 17:07:49 +0100 Subject: [PATCH 1/2] Avoid "." path in InotifyEventDriverWatchers. The vibe-core tests broke because a "/./" path segment slipped into the resulting paths. --- source/eventcore/drivers/posix/watchers.d | 4 ++-- tests/0-dirwatcher-rec.d | 4 +++- tests/0-dirwatcher.d | 9 ++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/eventcore/drivers/posix/watchers.d b/source/eventcore/drivers/posix/watchers.d index ad6c777..c36aaf9 100644 --- a/source/eventcore/drivers/posix/watchers.d +++ b/source/eventcore/drivers/posix/watchers.d @@ -41,7 +41,7 @@ final class InotifyEventDriverWatchers(Events : EventDriverEvents) : EventDriver m_watches[ret] = WatchState(null, path, recursive); - addWatch(ret, path, "."); + addWatch(ret, path, ""); if (recursive) { try { auto base_segements = path.pathSplitter.walkLength; @@ -138,7 +138,7 @@ final class InotifyEventDriverWatchers(Events : EventDriverEvents) : EventDriver auto subdir = w.watcherPaths[ev.wd]; if (w.recursive && ev.mask & (IN_CREATE|IN_MOVED_TO) && ev.mask & IN_ISDIR) { - addWatch(id, w.basePath, subdir == "." ? name.idup : buildPath(subdir, name)); + addWatch(id, w.basePath, subdir == "" ? name.idup : buildPath(subdir, name)); } ch.baseDirectory = m_watches[id].basePath; diff --git a/tests/0-dirwatcher-rec.d b/tests/0-dirwatcher-rec.d index fda5698..67cac90 100644 --- a/tests/0-dirwatcher-rec.d +++ b/tests/0-dirwatcher-rec.d @@ -160,5 +160,7 @@ print("test %s RENAME %s %s", from, to, expect_change); FileChange fchange(FileChangeKind kind, string name, bool is_dir) { - return FileChange(kind, testDir, dirName(name), baseName(name), is_dir); + auto dn = dirName(name); + if (dn == ".") dn = ""; + return FileChange(kind, testDir, dn, baseName(name), is_dir); } diff --git a/tests/0-dirwatcher.d b/tests/0-dirwatcher.d index a5468c9..c6ff710 100644 --- a/tests/0-dirwatcher.d +++ b/tests/0-dirwatcher.d @@ -27,17 +27,20 @@ void main() default: assert(false); case 0: assert(change.kind == FileChangeKind.added); - assert(change.directory == "."); + assert(change.baseDirectory == "."); + assert(change.directory == ""); assert(change.name == testFilename); break; case 1: assert(change.kind == FileChangeKind.modified); - assert(change.directory == "."); + assert(change.baseDirectory == "."); + assert(change.directory == ""); assert(change.name == testFilename); break; case 2: assert(change.kind == FileChangeKind.removed); - assert(change.directory == "."); + assert(change.baseDirectory == "."); + assert(change.directory == ""); assert(change.name == testFilename); eventDriver.watchers.releaseRef(id); s_done = true; From 16e95b03e828af3eb5f86753edcbabfc1588697e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Wed, 22 Nov 2017 17:14:31 +0100 Subject: [PATCH 2/2] Fix WinAPI watcher to be consistent. --- source/eventcore/drivers/winapi/watchers.d | 1 + 1 file changed, 1 insertion(+) diff --git a/source/eventcore/drivers/winapi/watchers.d b/source/eventcore/drivers/winapi/watchers.d index 2eff613..db9bae9 100644 --- a/source/eventcore/drivers/winapi/watchers.d +++ b/source/eventcore/drivers/winapi/watchers.d @@ -123,6 +123,7 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers { auto path = () @trusted { scope (failure) assert(false); return to!string(fni.FileName[0 .. fni.FileNameLength/2]); } (); auto fullpath = buildPath(slot.directory, path); ch.directory = dirName(path); + if (ch.directory == ".") ch.directory = ""; ch.name = baseName(path); try ch.isDirectory = isDir(fullpath); catch (Exception e) {} // FIXME: can happen if the base path is relative and the CWD has changed