Skip to content

Commit bcf3408

Browse files
committed
fix(del): don't remove tmp file if move failed
1 parent d035984 commit bcf3408

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

  • src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage

src/java/JavaFileStorage/app/src/main/java/keepass2android/javafilestorage/WebDavStorage.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -373,21 +373,8 @@ public void uploadFile(String path, byte[] data, boolean writeTransactional)
373373
if (writeTransactional)
374374
{
375375
String randomSuffix = ".tmp." + generateRandomHexString(8);
376-
try {
377-
// Upload to temporary file first
378-
uploadFile(path + randomSuffix, data, false);
379-
// Use enhanced move operation with delete-then-rename strategy
380-
renameOrMoveWebDavResource(path+randomSuffix, path, true);
381-
} catch (Exception e) {
382-
// If move fails, try to clean up the temporary file
383-
try {
384-
ConnectionInfo tempCi = splitStringToConnectionInfo(path + randomSuffix);
385-
deleteFileIfExists(tempCi);
386-
} catch (Exception cleanupException) {
387-
Log.w("WebDavStorage", "Failed to cleanup temporary file after failed transaction: " + cleanupException.getMessage());
388-
}
389-
throw e;
390-
}
376+
uploadFile(path + randomSuffix, data, false);
377+
renameOrMoveWebDavResource(path+randomSuffix, path, true);
391378
return;
392379
}
393380

0 commit comments

Comments
 (0)