Closed overheadhunter closed 6 years ago
Similar to issue #22:
When opening a file channel, cryptofs keeps some bytes cached. This causes problems when getting the file size from CryptoBasicFileAttributes#size().
Path p = cryptoFileSystem.getPath("/demo.txt"); try (FileChannel channel = FileChannel.open(p, CREATE, WRITE)) { channel.write(ByteBuffer.wrap(new byte[10])); assertEquals(10, channel.size()); // ok assertEquals(10, Files.size(p)); // error }
If the content gets flushed, everything works fine:
Path p = cryptoFileSystem.getPath("/demo.txt"); try (FileChannel channel = FileChannel.open(p, CREATE, WRITE)) { channel.write(ByteBuffer.wrap(new byte[10])); channel.force(false); assertEquals(10, channel.size()); // ok assertEquals(10, Files.size(p)); // ok }
We need to make sure, that BasicFileAttributes get the size from OpenCryptoFile#size(), if the file is currently opened.
Similar to issue #22:
When opening a file channel, cryptofs keeps some bytes cached. This causes problems when getting the file size from CryptoBasicFileAttributes#size().
If the content gets flushed, everything works fine:
We need to make sure, that BasicFileAttributes get the size from OpenCryptoFile#size(), if the file is currently opened.