mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
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:
+3
-1
@@ -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) {
|
||||
|
||||
+36
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user