JAL-3210 JAL-3141 JAL-3056 disable backups in JalviewJS
[jalview.git] / src / jalview / gui / AlignFrame.java
index a9d5b86..4bf424b 100644 (file)
@@ -1289,10 +1289,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         else
         {
           // create backupfiles object and get new temp filename destination
-          BackupFiles backupfiles = new BackupFiles(file);
+          boolean doBackup = BackupFiles.getEnabled();
+          BackupFiles backupfiles = doBackup ? new BackupFiles(file) : null;
           try
           {
-            String tempFilePath = backupfiles.getTempFilePath();
+            String tempFilePath = doBackup ? backupfiles.getTempFilePath() : file;
                        PrintWriter out = new PrintWriter(
                     new FileWriter(tempFilePath));
 
@@ -1302,15 +1303,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             statusBar.setText(MessageManager.formatMessage(
                   "label.successfully_saved_to_file_in_format", new Object[]
                   { fileName, format.getName() }));
+            lastSaveSuccessful = true;
           } catch (Exception ex)
           {
             lastSaveSuccessful = false;
             ex.printStackTrace();
           }
 
-          backupfiles.setWriteSuccess(lastSaveSuccessful);
-          // do the backup file roll and rename the temp file to actual file
-          lastSaveSuccessful = backupfiles.rollBackupsAndRenameTempFile();
+          if (doBackup)
+          {
+            backupfiles.setWriteSuccess(lastSaveSuccessful);
+            // do the backup file roll and rename the temp file to actual file
+            lastSaveSuccessful = backupfiles.rollBackupsAndRenameTempFile();
+          }
         }
       }
     };