platform: partial refresh fixed

Before, parts of the VFS tree (below some directory) may remain dirty indefinitely after non-recursive refresh in that directory
This commit is contained in:
Roman Shevchenko
2013-10-10 19:44:10 +02:00
parent af0637ca71
commit d8729d5077
3 changed files with 45 additions and 1 deletions
@@ -228,7 +228,9 @@ public class RefreshWorker {
}
}
file.markClean();
if (myIsRecursive || !file.isDirectory()) {
file.markClean();
}
}
}
@@ -674,6 +674,12 @@ public class FileWatcherTest extends PlatformLangTestCase {
}
}
public void testPartialRefresh() throws Exception {
// tests the same scenario with an active file watcher: this affects
File top = createTestDir("top");
LocalFileSystemTest.doTestPartialRefresh(top);
}
@NotNull
private LocalFileSystem.WatchRequest watch(File watchFile) {
@@ -437,4 +437,40 @@ public class LocalFileSystemTest extends PlatformLangTestCase {
assertTrue(sourceFile.isValid());
assertEquals(newName, sourceFile.getName());
}
public void testPartialRefresh() throws Exception {
File top = createTempDirectory(false);
doTestPartialRefresh(top);
}
public static void doTestPartialRefresh(File top) throws IOException {
File sub = IoTestUtil.createTestDir(top, "sub");
File file = IoTestUtil.createTestFile(top, "sub.txt");
LocalFileSystem lfs = LocalFileSystem.getInstance();
NewVirtualFile topDir = (NewVirtualFile)lfs.refreshAndFindFileByIoFile(top);
assertNotNull(topDir);
NewVirtualFile subDir = (NewVirtualFile)lfs.refreshAndFindFileByIoFile(sub);
assertNotNull(subDir);
NewVirtualFile subFile = (NewVirtualFile)lfs.refreshAndFindFileByIoFile(file);
assertNotNull(subFile);
topDir.refresh(false, true);
assertFalse(topDir.isDirty());
assertFalse(subDir.isDirty());
assertFalse(subFile.isDirty());
subFile.markDirty();
subDir.markDirty();
assertTrue(topDir.isDirty());
assertTrue(subFile.isDirty());
assertTrue(subDir.isDirty());
topDir.refresh(false, false);
assertFalse(subFile.isDirty());
assertTrue(subDir.isDirty()); // should stay unvisited after non-recursive refresh
topDir.refresh(false, true);
assertFalse(topDir.isDirty());
assertFalse(subFile.isDirty());
assertFalse(subDir.isDirty());
}
}