Skip to content

Commit

Permalink
Merge pull request #9675 from JabRef/remove-sav-file
Browse files Browse the repository at this point in the history
Always delete the `.sav` file upon successful write
  • Loading branch information
Siedlerchr committed Mar 27, 2023
2 parents f4f3b3d + 33c1a86 commit 9acf64b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- `log.txt` now contains debug messages. Debugging needs to be enabled explicitly. [#9678](https://github.com/JabRef/jabref/pull/9678)
- `log.txt` does not contain entries for non-found files during PDF indexing. [#9678](https://github.com/JabRef/jabref/pull/9678)
- We improved the Medline importer to correctly import ISO dates for `revised`. [#9536](https://github.com/JabRef/jabref/issues/9536)
- To avoid cluttering of the directory, We always delete the `.sav` file upon successful write. [#9675](https://github.com/JabRef/jabref/pull/9675)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class AtomicFileOutputStream extends FilterOutputStream {
private final Path temporaryFile;

private final FileLock temporaryFileLock;

/**
* A backup of the target file (if it exists), created when the stream is closed
*/
Expand All @@ -75,7 +76,7 @@ public class AtomicFileOutputStream extends FilterOutputStream {
* Creates a new output stream to write to or replace the file at the specified path.
*
* @param path the path of the file to write to or replace
* @param keepBackup whether to keep the backup file after a successful write process
* @param keepBackup whether to keep the backup file (.sav) after a successful write process
*/
public AtomicFileOutputStream(Path path, boolean keepBackup) throws IOException {
// Files.newOutputStream(getPathOfTemporaryFile(path)) leads to a "sun.nio.ch.ChannelOutputStream", which does not offer "lock"
Expand All @@ -84,7 +85,7 @@ public AtomicFileOutputStream(Path path, boolean keepBackup) throws IOException

/**
* Creates a new output stream to write to or replace the file at the specified path.
* The backup file is deleted when write was successful.
* The backup file (.sav) is deleted when write was successful.
*
* @param path the path of the file to write to or replace
*/
Expand Down Expand Up @@ -238,7 +239,7 @@ public void close() throws IOException {
}

if (!keepBackup) {
// Remove backup file
// Remove backup file for saving
Files.deleteIfExists(backupFile);
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public SavePreferences(Boolean saveInOriginalOrder,

this(saveInOriginalOrder,
saveOrder,
true,
false,
saveType,
takeMetadataSaveOrderInAccount,
reformatFile,
Expand Down

0 comments on commit 9acf64b

Please sign in to comment.