File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
src/main/java/org/cryptomator/cryptofs/ch Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -208,11 +208,7 @@ public void force(boolean metaData) throws IOException {
208
208
}
209
209
210
210
private void forceInternal (boolean metaData ) throws IOException {
211
- if (isWritable ()) {
212
- writeHeaderIfNeeded ();
213
- chunkCache .invalidateAll (); // TODO performance: write chunks but keep them cached
214
- exceptionsDuringWrite .throwIfPresent ();
215
- }
211
+ flush ();
216
212
ciphertextFileChannel .force (metaData );
217
213
if (metaData ) {
218
214
FileTime lastModifiedTime = isWritable () ? FileTime .from (lastModified .get ()) : null ;
@@ -221,6 +217,18 @@ private void forceInternal(boolean metaData) throws IOException {
221
217
}
222
218
}
223
219
220
+ /**
221
+ * Writes in-memory contents to the ciphertext file
222
+ * @throws IOException
223
+ */
224
+ private void flush () throws IOException {
225
+ if (isWritable ()) {
226
+ writeHeaderIfNeeded ();
227
+ chunkCache .invalidateAll (); // TODO performance: write chunks but keep them cached
228
+ exceptionsDuringWrite .throwIfPresent ();
229
+ }
230
+ }
231
+
224
232
@ Override
225
233
public MappedByteBuffer map (MapMode mode , long position , long size ) {
226
234
throw new UnsupportedOperationException ();
@@ -285,7 +293,7 @@ long beginOfChunk(long cleartextPos) {
285
293
@ Override
286
294
protected void implCloseChannel () throws IOException {
287
295
try {
288
- forceInternal ( true );
296
+ flush ( );
289
297
} finally {
290
298
super .implCloseChannel ();
291
299
closeListener .closed (this );
You can’t perform that action at this time.
0 commit comments