Skip to content

Commit

Permalink
Can't Save a Database to a new File (JabRef#3022)
Browse files Browse the repository at this point in the history
* Updated maven repo

* #1 fixed, in case the old file is not there we just save the new file

* #1 adjustments

* #1 adjustments

* fixes for checkstyle and improvements on file path verification
  • Loading branch information
zacmks authored and LinusDietz committed Jul 18, 2017
1 parent 1116331 commit c08c5d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Sun Jul 09 12:08:20 CEST 2017
#Tue Jul 18 01:58:04 BRT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ public void saveAs() throws Exception {
*/
public void saveAs(File file) throws Exception {
BibDatabaseContext context = panel.getBibDatabaseContext();
Path oldFile = context.getDatabasePath().get();


if (context.getLocation() == DatabaseLocation.SHARED) {
// Save all properties dependent on the ID. This makes it possible to restore them.
DBMSConnectionProperties properties = context.getDBMSSynchronizer().getDBProcessor()
Expand All @@ -336,12 +335,18 @@ public void saveAs(File file) throws Exception {
return;
}

//closing AutosaveManager and BackupManager for original library
context.setDatabaseFile(oldFile.toFile());
AutosaveManager.shutdown(context);
BackupManager.shutdown(context);
Optional<Path> databasePath = context.getDatabasePath();
if (databasePath.isPresent()) {
final Path oldFile = databasePath.get();
context.setDatabaseFile(oldFile.toFile());
//closing AutosaveManager and BackupManager for original library
AutosaveManager.shutdown(context);
BackupManager.shutdown(context);
} else {
LOGGER.info("Old file not found, just creating a new file");
}
context.setDatabaseFile(file);

// Register so we get notifications about outside changes to the file.
try {
panel.setFileMonitorHandle(Globals.getFileUpdateMonitor().addUpdateListener(panel,
Expand Down

0 comments on commit c08c5d4

Please sign in to comment.