Due to TRUNCATE_EXISTING flag being passed through to the ciphertext file channel, the ciphertext file size is reset to zero as soon as the method is invoked, which causes a new header to be created:
As already specified in #48: Yes TRUNCATE_EXISTINGshould generate a new header. However FileHeaderHolder will only generate a header once due to this atomic CAS operation:
On CI (not reproducible on all setups, though)
testTruncateExistingWhileStillOpen
fails.Due to
TRUNCATE_EXISTING
flag being passed through to the ciphertext file channel, the ciphertext file size is reset to zero as soon as the method is invoked, which causes a new header to be created:https://github.com/cryptomator/cryptofs/blob/e1704e8b11f6471cc847f0c854ee41dfaaa2db2c/src/main/java/org/cryptomator/cryptofs/fh/OpenCryptoFile.java#L68-L87
I'm currently unsure, if this is desirable behaviour (and the test is broken) or the existing header should really be kept.