use of com.intellij.openapi.vfs.newvfs.FileAttribute in project intellij-community by JetBrains.
the class PersistentFsTest method testModCountNotIncreases.
public void testModCountNotIncreases() throws IOException {
VirtualFile vFile = setupFile();
ManagingFS managingFS = ManagingFS.getInstance();
final int globalModCount = managingFS.getFilesystemModificationCount();
final int parentModCount = managingFS.getModificationCount(vFile.getParent());
int inSessionModCount = managingFS.getModificationCount();
FSRecords.force();
assertFalse(FSRecords.isDirty());
FileAttribute attribute = new FileAttribute("test.attribute", 1, true);
WriteAction.run(() -> {
try (DataOutputStream output = attribute.writeAttribute(vFile)) {
DataInputOutputUtil.writeINT(output, 1);
}
});
assertEquals(globalModCount, managingFS.getModificationCount(vFile));
assertEquals(globalModCount, managingFS.getFilesystemModificationCount());
assertEquals(parentModCount, managingFS.getModificationCount(vFile.getParent()));
assertEquals(inSessionModCount + 1, managingFS.getModificationCount());
assertTrue(FSRecords.isDirty());
FSRecords.force();
assertFalse(FSRecords.isDirty());
//
int fileId = ((VirtualFileWithId) vFile).getId();
FSRecords.setTimestamp(fileId, FSRecords.getTimestamp(fileId));
FSRecords.setLength(fileId, FSRecords.getLength(fileId));
assertEquals(globalModCount, managingFS.getModificationCount(vFile));
assertEquals(globalModCount, managingFS.getFilesystemModificationCount());
assertEquals(parentModCount, managingFS.getModificationCount(vFile.getParent()));
assertEquals(inSessionModCount + 1, managingFS.getModificationCount());
assertFalse(FSRecords.isDirty());
}
Aggregations