Skip to content

Commit

Permalink
Fix saving on network drive under macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Oct 6, 2023
1 parent 303281e commit 3d672c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where it was possible to create a group with no name or with a group separator inside the name [#9776](https://github.com/JabRef/jabref/issues/9776)
- Biblatex's `journaltitle` is now also respected for showing the journal information. [#10397](https://github.com/JabRef/jabref/issues/10397)
- JabRef does not hang anymore when exporting via CLI. [#10380](https://github.com/JabRef/jabref/issues/10380)
- We fixed an issue where it was not possible to save a library on a network share under macOS due to an exception when acquiring a file lock [#10452](https://github.com/JabRef/jabref/issues/10452)

### Removed

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

private final FileLock temporaryFileLock;
private FileLock temporaryFileLock;

/**
* A backup of the target file (if it exists), created when the stream is closed
Expand Down Expand Up @@ -106,7 +106,12 @@ public AtomicFileOutputStream(Path path) throws IOException {
try {
// Lock files (so that at least not another JabRef instance writes at the same time to the same tmp file)
if (out instanceof FileOutputStream stream) {
temporaryFileLock = stream.getChannel().lock();
try {
temporaryFileLock = stream.getChannel().tryLock();
} catch (IOException ex) {
LOGGER.warn("Could not acquire file lock. Maybe we are on a network drive?", ex);
temporaryFileLock = null;
}
} else {
temporaryFileLock = null;
}
Expand Down

0 comments on commit 3d672c0

Please sign in to comment.