Search in sources :

Example 1 with FileAttribute

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());
}
Also used : NewVirtualFile(com.intellij.openapi.vfs.newvfs.NewVirtualFile) DataOutputStream(java.io.DataOutputStream) ManagingFS(com.intellij.openapi.vfs.newvfs.ManagingFS) FileAttribute(com.intellij.openapi.vfs.newvfs.FileAttribute)

Aggregations

FileAttribute (com.intellij.openapi.vfs.newvfs.FileAttribute)1 ManagingFS (com.intellij.openapi.vfs.newvfs.ManagingFS)1 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)1 DataOutputStream (java.io.DataOutputStream)1