Skip to content

Commit

Permalink
Merge pull request #10454 from JabRef/fixSavingFileLockNetworkShare
Browse files Browse the repository at this point in the history
Fix saving on network drive under macOS
  • Loading branch information
Siedlerchr authored Oct 7, 2023
2 parents 3f53201 + 9aeb791 commit ca00d64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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)
- We fixed an issue where exporting "XMP annotated pdf" without selecting an existing document would produce an exception. [#10102](https://github.com/JabRef/jabref/issues/10102)

### 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,13 @@ 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) {
// workaround for https://bugs.openjdk.org/browse/JDK-8167023
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 ca00d64

Please sign in to comment.