Skip to content

Commit

Permalink
fix: add file existence check before save
Browse files Browse the repository at this point in the history
  • Loading branch information
ZEROM22 committed Sep 17, 2024
1 parent 09344f6 commit 14df5fc
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ public static void processSave(final JSONObject body,
ver.mkdirs();
}

// get the path to the previous file version and rename the last file version with it
lastVersion.renameTo(new File(versionDir + File.separator + "prev." + curExt));
if (lastVersion.exists()) {
// get the path to the previous file version and rename the last file version with it
lastVersion.renameTo(new File(versionDir + File.separator + "prev." + curExt));
} else {
throw new Exception("The file not exist: " + lastVersion.getAbsolutePath());
}

saveFile(byteArrayFile, toSave); // save document file

Expand Down

0 comments on commit 14df5fc

Please sign in to comment.