Closed overheadhunter closed 6 years ago
When opening a file channel, cryptofs doesn't immediately write the file header. This causes problems when determining the file size as currently implemented in CryptoBasicFileAttributes, as the file header is subtracted from an empty file.
Path p = cryptoFileSystem.getPath("/demo.txt"); try (FileChannel channel = FileChannel.open(p, CREATE, WRITE)) { assertEquals(0, channel.size()); // ok assertEquals(0, Files.size(p)); // error }
If the header gets written (by flushing the channel first), everything works fine:
Path p = cryptoFileSystem.getPath("/demo.txt"); try (FileChannel channel = FileChannel.open(p, CREATE, WRITE)) { channel.force(false); assertEquals(0, channel.size()); // ok assertEquals(0, Files.size(p)); // ok }
When opening a file channel, cryptofs doesn't immediately write the file header. This causes problems when determining the file size as currently implemented in CryptoBasicFileAttributes, as the file header is subtracted from an empty file.
If the header gets written (by flushing the channel first), everything works fine: