git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1aa00eb
)
JAL-3141 Tidying
author
Ben Soares
<bsoares@dundee.ac.uk>
Mon, 22 Oct 2018 09:25:09 +0000
(10:25 +0100)
committer
Ben Soares
<bsoares@dundee.ac.uk>
Mon, 22 Oct 2018 09:25:09 +0000
(10:25 +0100)
src/jalview/io/JalviewFileChooser.java
patch
|
blob
|
history
diff --git
a/src/jalview/io/JalviewFileChooser.java
b/src/jalview/io/JalviewFileChooser.java
index
983800b
..
052cf68
100755
(executable)
--- a/
src/jalview/io/JalviewFileChooser.java
+++ b/
src/jalview/io/JalviewFileChooser.java
@@
-353,18
+353,31
@@
public class JalviewFileChooser extends JFileChooser
}
rollBackupFiles(ourselectedFile);
}
rollBackupFiles(ourselectedFile);
-
}
return ret;
}
// attempts to roll backup files for this file (before overwriting). Returns
}
return ret;
}
// attempts to roll backup files for this file (before overwriting). Returns
- // true if it rolled all the files, false otherwise.
- private static boolean rollBackupFiles(File file)
+ // true if it rolled all the files it was supposed to, false otherwise.
+ public static boolean rollBackupFiles(String filename)
{
{
+ File file = new File(filename);
+ return rollBackupFiles(file);
+ }
+
+ public static boolean rollBackupFiles(File file)
+ {
+ return rollBackupFiles(file, true, "-bak-%n", 4);
+ }
- if (!file.exists())
+ public static boolean rollBackupFiles(File file, boolean defaultDo,
+ String defaultSuffix, int defaultMax)
+ {
+
+ if (!(file.exists()
+ && jalview.bin.Cache.getDefault("BACKUP_FILES",
+ defaultDo)))
{
// nothing to do
return true;
{
// nothing to do
return true;
@@
-373,8
+386,9
@@
public class JalviewFileChooser extends JFileChooser
// split filename up to insert suffix template in the right place. template
// and backupMax can be set in .jalview_properties
String backupSuffixTemplate = jalview.bin.Cache
// split filename up to insert suffix template in the right place. template
// and backupMax can be set in .jalview_properties
String backupSuffixTemplate = jalview.bin.Cache
- .getDefault("BACKUP_SUFFIX", "-bak-%n");
- int backupMax = jalview.bin.Cache.getDefault("BACKUP_MAX", 10);
+ .getDefault("BACKUP_SUFFIX", defaultSuffix);
+ int backupMax = jalview.bin.Cache.getDefault("BACKUP_ROLL_MAX",
+ defaultMax);
String dir = "";
try
{
String dir = "";
try
{
@@
-418,10
+432,10
@@
public class JalviewFileChooser extends JFileChooser
continue;
}
continue;
}
- if (n == backupMax-1)
+ if (n == backupMax)
{ // Move the max backup to /tmp instead of deleting (Just In
// Case)
{ // Move the max backup to /tmp instead of deleting (Just In
// Case)
- String tmpfile = "tmp-" + backupfilename;
+ String tmpfile = "tmp-" + backupfile_n.getName();
try
{
File tmpFile = File.createTempFile(tmpfile, ".tmp");
try
{
File tmpFile = File.createTempFile(tmpfile, ".tmp");
@@
-434,7
+448,11
@@
public class JalviewFileChooser extends JFileChooser
}
else
{
}
else
{
- ret = ret && backupfile_n.renameTo(lastfile);
+ // Just In Case
+ if (lastfile != null)
+ {
+ ret = ret && backupfile_n.renameTo(lastfile);
+ }
}
lastfile = backupfile_n;
}
lastfile = backupfile_n;