2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import java.io.IOException;
25 import java.nio.file.Files;
26 import java.nio.file.Path;
27 import java.nio.file.Paths;
28 import java.nio.file.StandardCopyOption;
29 import java.text.SimpleDateFormat;
30 import java.util.ArrayList;
31 import java.util.HashMap;
33 import java.util.TreeMap;
35 import jalview.bin.Cache;
36 import jalview.gui.Desktop;
37 import jalview.gui.JvOptionPane;
38 import jalview.util.MessageManager;
39 import jalview.util.Platform;
42 * BackupFiles used for manipulating (naming rolling/deleting) backup/version files when an alignment or project file is saved.
43 * User configurable options are:
44 * BACKUPFILES_ENABLED - boolean flag as to whether to use this mechanism or act as before, including overwriting files as saved.
45 * The rest of the options are now saved as BACKUPFILES_PRESET, BACKUPFILES_SAVED and BACKUPFILES_CUSTOM
46 * (see BackupFilesPresetEntry)
49 public class BackupFiles
52 // labels for saved params in Cache and .jalview_properties
53 public static final String NS = "BACKUPFILES";
55 public static final String ENABLED = NS + "_ENABLED";
57 public static final String NUM_PLACEHOLDER = "%n";
59 private static final String DEFAULT_TEMP_FILE = "jalview_temp_file_" + NS;
61 private static final String TEMP_FILE_EXT = ".tmp";
63 // file - File object to be backed up and then updated (written over)
66 // enabled - default flag as to whether to do the backup file roll (if not
67 // defined in preferences)
68 private static boolean enabled;
70 // confirmDelete - default flag as to whether to confirm with the user before
71 // deleting old backup/version files
72 private static boolean confirmDelete;
74 // defaultSuffix - default template to use to append to basename of file
75 private String suffix;
77 // noMax - flag to turn off a maximum number of files
78 private boolean noMax;
80 // defaultMax - default max number of backup files
83 // defaultDigits - number of zero-led digits to use in the filename
86 // reverseOrder - set to true to make newest (latest) files lowest number
87 // (like rolled log files)
88 private boolean reverseOrder;
90 // temp saved file to become new saved file
91 private File tempFile;
93 // flag set to see if file save to temp file was successful
94 private boolean tempFileWriteSuccess;
96 // array of files to be deleted, with extra information
97 private ArrayList<File> deleteFiles = new ArrayList<>();
99 // date formatting for modification times
100 private static final SimpleDateFormat sdf = new SimpleDateFormat(
101 "yyyy-MM-dd HH:mm:ss");
103 private static final String newTempFileSuffix = "_newfile";
105 private static final String oldTempFileSuffix = "_oldfile_tobedeleted";
107 public BackupFiles(String filename)
109 this(new File(filename));
112 // first time defaults for SUFFIX, NO_MAX, ROLL_MAX, SUFFIX_DIGITS and
114 public BackupFiles(File file)
118 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
119 .getSavedBackupEntry();
120 this.suffix = bfpe.suffix;
121 this.noMax = bfpe.keepAll;
122 this.max = bfpe.rollMax;
123 this.digits = bfpe.digits;
124 this.reverseOrder = bfpe.reverse;
126 // create a temp file to save new data in
132 String tempfilename = file.getName();
133 File tempdir = file.getParentFile();
135 "BACKUPFILES [file!=null] attempting to create temp file "
136 + tempfilename + " in dir " + tempdir);
137 temp = File.createTempFile(tempfilename,
138 TEMP_FILE_EXT + newTempFileSuffix, tempdir);
143 "BACKUPFILES [file==null] attempting to create default temp file "
144 + DEFAULT_TEMP_FILE + " with extension "
146 temp = File.createTempFile(DEFAULT_TEMP_FILE, TEMP_FILE_EXT);
148 } catch (IOException e)
151 .error("Could not create temp file to save to (IOException)");
152 Cache.log.error(e.getMessage());
153 Cache.log.debug(e.getStackTrace());
154 } catch (Exception e)
156 Cache.log.error("Exception creating temp file for saving");
157 Cache.log.debug(e.getStackTrace());
159 this.setTempFile(temp);
162 public static void classInit()
164 Cache.log.debug("BACKUPFILES classInit");
165 setEnabled(Cache.getDefault(ENABLED, !Platform.isJS()));
166 BackupFilesPresetEntry bfpe = BackupFilesPresetEntry
167 .getSavedBackupEntry();
168 setConfirmDelete(bfpe.confirmDelete);
171 public static void setEnabled(boolean flag)
176 public static boolean getEnabled()
182 public static void setConfirmDelete(boolean flag)
184 confirmDelete = flag;
187 public static boolean getConfirmDelete()
190 return confirmDelete;
193 // set, get and rename temp file into place
194 public void setTempFile(File temp)
196 this.tempFile = temp;
199 public File getTempFile()
204 public String getTempFilePath()
209 path = this.getTempFile().getCanonicalPath();
210 } catch (IOException e)
213 "IOException when getting Canonical Path of temp file '"
214 + this.getTempFile().getName() + "'");
215 Cache.log.debug(e.getStackTrace());
220 public boolean setWriteSuccess(boolean flag)
222 boolean old = this.tempFileWriteSuccess;
223 this.tempFileWriteSuccess = flag;
227 public boolean getWriteSuccess()
229 return this.tempFileWriteSuccess;
232 public boolean renameTempFile()
234 return moveFileToFile(tempFile, file);
237 // roll the backupfiles
238 public boolean rollBackupFiles()
240 return this.rollBackupFiles(true);
243 public boolean rollBackupFiles(boolean tidyUp)
245 // file doesn't yet exist or backups are not enabled or template is null or
247 if ((!file.exists()) || (!enabled) || max < 0 || suffix == null
248 || suffix.length() == 0)
251 Cache.log.debug("BACKUPFILES rollBackupFiles nothing to do." + ", "
252 + "filename: " + (file != null ? file.getName() : "null")
253 + ", " + "file exists: " + file.exists() + ", " + "enabled: "
254 + enabled + ", " + "max: " + max + ", " + "suffix: '" + suffix
259 Cache.log.debug("BACKUPFILES rollBackupFiles starting");
265 dirFile = file.getParentFile();
266 dir = dirFile.getCanonicalPath();
267 Cache.log.debug("BACKUPFILES dir: " + dir);
268 } catch (Exception e)
271 "Could not get canonical path for file '" + file + "'");
272 Cache.log.error(e.getMessage());
273 Cache.log.debug(e.getStackTrace());
276 String filename = file.getName();
277 String basename = filename;
279 Cache.log.debug("BACKUPFILES filename is " + filename);
281 // Create/move backups up one
285 // find existing backup files
286 BackupFilenameFilter bff = new BackupFilenameFilter(basename, suffix,
288 File[] backupFiles = dirFile.listFiles(bff);
289 int nextIndexNum = 0;
292 .debug("BACKUPFILES backupFiles.length: " + backupFiles.length);
293 if (backupFiles.length == 0)
295 // No other backup files. Just need to move existing file to backupfile_1
297 "BACKUPFILES no existing backup files, setting index to 1");
302 TreeMap<Integer, File> bfTreeMap = sortBackupFilesAsTreeMap(
303 backupFiles, basename);
304 // bfTreeMap now a sorted list of <Integer index>,<File backupfile>
309 // backup style numbering
310 Cache.log.debug("BACKUPFILES rolling files in reverse order");
312 int tempMax = noMax ? -1 : max;
313 // noMax == true means no limits
314 // look for first "gap" in backupFiles
315 // if tempMax is -1 at this stage just keep going until there's a gap,
316 // then hopefully tempMax gets set to the right index (a positive
317 // integer so the loop breaks)...
318 // why do I feel a little uneasy about this loop?..
319 for (int i = 1; tempMax < 0 || i <= max; i++)
321 if (!bfTreeMap.containsKey(i)) // first index without existent
328 File previousFile = null;
329 File fileToBeDeleted = null;
330 for (int n = tempMax; n > 0; n--)
332 String backupfilename = dir + File.separatorChar
333 + BackupFilenameParts.getBackupFilename(n, basename,
335 File backupfile_n = new File(backupfilename);
337 if (!backupfile_n.exists())
339 // no "oldest" file to delete
340 previousFile = backupfile_n;
341 fileToBeDeleted = null;
342 Cache.log.debug("BACKUPFILES No oldest file to delete");
346 // check the modification time of this (backupfile_n) and the previous
347 // file (fileToBeDeleted) if the previous file is going to be deleted
348 if (fileToBeDeleted != null)
350 File replacementFile = backupfile_n;
351 long fileToBeDeletedLMT = fileToBeDeleted.lastModified();
352 long replacementFileLMT = replacementFile.lastModified();
353 Cache.log.debug("BACKUPFILES fileToBeDeleted is "
354 + fileToBeDeleted.getAbsolutePath());
355 Cache.log.debug("BACKUPFILES replacementFile is "
356 + backupfile_n.getAbsolutePath());
360 File oldestTempFile = nextTempFile(fileToBeDeleted.getName(),
363 if (fileToBeDeletedLMT > replacementFileLMT)
365 String fileToBeDeletedLMTString = sdf
366 .format(fileToBeDeletedLMT);
367 String replacementFileLMTString = sdf
368 .format(replacementFileLMT);
369 Cache.log.warn("WARNING! I am set to delete backupfile "
370 + fileToBeDeleted.getName()
371 + " has modification time "
372 + fileToBeDeletedLMTString
373 + " which is newer than its replacement "
374 + replacementFile.getName()
375 + " with modification time "
376 + replacementFileLMTString);
378 boolean delete = confirmNewerDeleteFile(fileToBeDeleted,
379 replacementFile, true);
380 Cache.log.debug("BACKUPFILES "
381 + (delete ? "confirmed" : "not") + " deleting file "
382 + fileToBeDeleted.getAbsolutePath()
383 + " which is newer than "
384 + replacementFile.getAbsolutePath());
388 // User has confirmed delete -- no need to add it to the list
389 fileToBeDeleted.delete();
393 Cache.log.debug("BACKUPFILES moving "
394 + fileToBeDeleted.getAbsolutePath() + " to "
395 + oldestTempFile.getAbsolutePath());
396 moveFileToFile(fileToBeDeleted, oldestTempFile);
401 Cache.log.debug("BACKUPFILES going to move "
402 + fileToBeDeleted.getAbsolutePath() + " to "
403 + oldestTempFile.getAbsolutePath());
404 moveFileToFile(fileToBeDeleted, oldestTempFile);
405 addDeleteFile(oldestTempFile);
408 } catch (Exception e)
411 "Error occurred, probably making new temp file for '"
412 + fileToBeDeleted.getName() + "'");
413 Cache.log.error(e.getStackTrace());
417 fileToBeDeleted = null;
420 if (!noMax && n == tempMax && backupfile_n.exists())
422 fileToBeDeleted = backupfile_n;
426 if (previousFile != null)
428 ret = ret && moveFileToFile(backupfile_n, previousFile);
432 previousFile = backupfile_n;
435 // index to use for the latest backup
438 else // not reverse numbering
440 // version style numbering (with earliest file deletion if max files
443 bfTreeMap.values().toArray(backupFiles);
444 StringBuilder bfsb = new StringBuilder();
445 for (int i = 0; i < backupFiles.length; i++)
447 if (bfsb.length() > 0)
451 bfsb.append(backupFiles[i].getName());
453 Cache.log.debug("BACKUPFILES backupFiles: " + bfsb.toString());
455 // noMax == true means keep all backup files
456 if ((!noMax) && bfTreeMap.size() >= max)
458 Cache.log.debug("BACKUPFILES noMax: " + noMax + ", " + "max: "
459 + max + ", " + "bfTreeMap.size(): " + bfTreeMap.size());
460 // need to delete some files to keep number of backups to designated
462 // Note that if the suffix is not numbered then do not delete any
463 // backup files later or we'll delete the new backup file (there can
465 int numToDelete = suffix.indexOf(NUM_PLACEHOLDER) > -1
466 ? bfTreeMap.size() - max + 1
468 Cache.log.debug("BACKUPFILES numToDelete: " + numToDelete);
469 // the "replacement" file is the latest backup file being kept (it's
470 // not replacing though)
471 File replacementFile = numToDelete < backupFiles.length
472 ? backupFiles[numToDelete]
474 for (int i = 0; i < numToDelete; i++)
476 // check the deletion files for modification time of the last
477 // backupfile being saved
478 File fileToBeDeleted = backupFiles[i];
479 boolean delete = true;
482 "BACKUPFILES fileToBeDeleted: " + fileToBeDeleted);
484 boolean newer = false;
485 if (replacementFile != null)
487 long fileToBeDeletedLMT = fileToBeDeleted.lastModified();
488 long replacementFileLMT = replacementFile != null
489 ? replacementFile.lastModified()
491 if (fileToBeDeletedLMT > replacementFileLMT)
493 String fileToBeDeletedLMTString = sdf
494 .format(fileToBeDeletedLMT);
495 String replacementFileLMTString = sdf
496 .format(replacementFileLMT);
498 Cache.log.warn("WARNING! I am set to delete backupfile '"
499 + fileToBeDeleted.getName()
500 + "' has modification time "
501 + fileToBeDeletedLMTString
502 + " which is newer than the oldest backupfile being kept '"
503 + replacementFile.getName()
504 + "' with modification time "
505 + replacementFileLMTString);
507 delete = confirmNewerDeleteFile(fileToBeDeleted,
508 replacementFile, false);
511 // User has confirmed delete -- no need to add it to the list
512 fileToBeDeleted.delete();
513 Cache.log.debug("BACKUPFILES deleting fileToBeDeleted: "
519 // keeping file, nothing to do!
520 Cache.log.debug("BACKUPFILES keeping fileToBeDeleted: "
527 addDeleteFile(fileToBeDeleted);
528 Cache.log.debug("BACKUPFILES addDeleteFile(fileToBeDeleted): "
536 nextIndexNum = bfTreeMap.lastKey() + 1;
540 // Let's make the new backup file!! yay, got there at last!
541 String latestBackupFilename = dir + File.separatorChar
542 + BackupFilenameParts.getBackupFilename(nextIndexNum, basename,
544 Cache.log.debug("BACKUPFILES Moving old file [" + file
545 + "] to latestBackupFilename [" + latestBackupFilename + "]");
546 ret |= moveFileToFile(file, new File(latestBackupFilename));
547 Cache.log.debug("BACKUPFILES moving " + latestBackupFilename + " to "
548 + file + " was " + (ret ? "" : "NOT ") + "successful");
552 Cache.log.debug("BACKUPFILES tidying up files");
559 private static File nextTempFile(String filename, File dirFile)
563 COUNT: for (int i = 1; i < 1000; i++)
565 File trythis = new File(dirFile,
566 filename + '~' + Integer.toString(i));
567 if (!trythis.exists())
576 temp = File.createTempFile(filename, TEMP_FILE_EXT, dirFile);
581 private void tidyUpFiles()
586 private static boolean confirmNewerDeleteFile(File fileToBeDeleted,
587 File replacementFile, boolean replace)
589 StringBuilder messageSB = new StringBuilder();
591 File ftbd = fileToBeDeleted;
592 String ftbdLMT = sdf.format(ftbd.lastModified());
593 String ftbdSize = Long.toString(ftbd.length());
595 File rf = replacementFile;
596 String rfLMT = sdf.format(rf.lastModified());
597 String rfSize = Long.toString(rf.length());
599 int confirmButton = JvOptionPane.NO_OPTION;
602 File saveFile = null;
605 saveFile = nextTempFile(ftbd.getName(), ftbd.getParentFile());
606 } catch (Exception e)
609 "Error when confirming to keep backup file newer than other backup files.");
612 messageSB.append(MessageManager.formatMessage(
613 "label.newerdelete_replacement_line", new String[]
614 { ftbd.getName(), rf.getName(), ftbdLMT, rfLMT, ftbdSize,
616 // "Backup file\n''{0}''\t(modified {2}, size {4})\nis to be deleted and
617 // replaced by apparently older file \n''{1}''\t(modified {3}, size
619 messageSB.append("\n\n");
620 messageSB.append(MessageManager.formatMessage(
621 "label.confirm_deletion_or_rename", new String[]
622 { ftbd.getName(), saveFile.getName() }));
623 // "Confirm deletion of ''{0}'' or rename to ''{1}''?"
624 String[] options = new String[] {
625 MessageManager.getString("label.delete"),
626 MessageManager.getString("label.rename") };
628 confirmButton = Platform.isHeadless() ? JvOptionPane.YES_OPTION
629 : JvOptionPane.showOptionDialog(Desktop.desktop,
630 messageSB.toString(),
631 MessageManager.getString(
632 "label.backupfiles_confirm_delete"),
634 JvOptionPane.YES_NO_OPTION,
635 JvOptionPane.WARNING_MESSAGE, null, options,
640 messageSB.append(MessageManager
641 .formatMessage("label.newerdelete_line", new String[]
642 { ftbd.getName(), rf.getName(), ftbdLMT, rfLMT, ftbdSize,
644 // "Backup file\n''{0}''\t(modified {2}, size {4})\nis to be deleted but
645 // is newer than the oldest remaining backup file \n''{1}''\t(modified
647 messageSB.append("\n\n");
648 messageSB.append(MessageManager
649 .formatMessage("label.confirm_deletion", new String[]
650 { ftbd.getName() }));
651 // "Confirm deletion of ''{0}''?"
652 String[] options = new String[] {
653 MessageManager.getString("label.delete"),
654 MessageManager.getString("label.keep") };
656 confirmButton = Platform.isHeadless() ? JvOptionPane.YES_OPTION
657 : JvOptionPane.showOptionDialog(Desktop.desktop,
658 messageSB.toString(),
659 MessageManager.getString(
660 "label.backupfiles_confirm_delete"),
662 JvOptionPane.YES_NO_OPTION,
663 JvOptionPane.WARNING_MESSAGE, null, options,
667 // return should be TRUE if file is to be deleted
668 return (confirmButton == JvOptionPane.YES_OPTION);
671 private void deleteOldFiles()
673 if (deleteFiles != null && !deleteFiles.isEmpty())
675 boolean doDelete = false;
676 StringBuilder messageSB = null;
677 if (confirmDelete && deleteFiles.size() > 0)
679 messageSB = new StringBuilder();
680 messageSB.append(MessageManager
681 .getString("label.backupfiles_confirm_delete_old_files"));
682 // "Delete the following older backup files? (see the Backups tab in
683 // Preferences for more options)"
684 for (int i = 0; i < deleteFiles.size(); i++)
686 File df = deleteFiles.get(i);
687 messageSB.append("\n");
688 messageSB.append(df.getName());
689 messageSB.append(" ");
690 messageSB.append(MessageManager.formatMessage("label.file_info",
692 { sdf.format(df.lastModified()),
693 Long.toString(df.length()) }));
694 // "(modified {0}, size {1})"
697 int confirmButton = Platform.isHeadless() ? JvOptionPane.YES_OPTION
698 : JvOptionPane.showConfirmDialog(Desktop.desktop,
699 messageSB.toString(),
700 MessageManager.getString(
701 "label.backupfiles_confirm_delete"),
703 JvOptionPane.YES_NO_OPTION,
704 JvOptionPane.WARNING_MESSAGE);
706 doDelete = (confirmButton == JvOptionPane.YES_OPTION);
715 for (int i = 0; i < deleteFiles.size(); i++)
717 File fileToDelete = deleteFiles.get(i);
719 "BACKUPFILES deleting fileToDelete:" + fileToDelete);
720 fileToDelete.delete();
721 Cache.log.warn("deleting '" + fileToDelete.getName() + "'");
730 private TreeMap<Integer, File> sortBackupFilesAsTreeMap(
731 File[] backupFiles, String basename)
733 // sort the backup files (based on integer found in the suffix) using a
734 // precomputed Hashmap for speed
735 Map<Integer, File> bfHashMap = new HashMap<>();
736 for (int i = 0; i < backupFiles.length; i++)
738 File f = backupFiles[i];
739 BackupFilenameParts bfp = new BackupFilenameParts(f, basename, suffix,
741 bfHashMap.put(bfp.indexNum(), f);
743 TreeMap<Integer, File> bfTreeMap = new TreeMap<>();
744 bfTreeMap.putAll(bfHashMap);
748 public boolean rollBackupsAndRenameTempFile()
750 boolean write = this.getWriteSuccess();
752 boolean roll = false;
753 boolean rename = false;
756 roll = this.rollBackupFiles(false); // tidyUpFiles at the end
757 rename = this.renameTempFile();
761 * Not sure that this confirmation is desirable. By this stage the new file is
762 * already written successfully, but something (e.g. disk full) has happened while
763 * trying to roll the backup files, and most likely the filename needed will already
764 * be vacant so renaming the temp file is nearly always correct!
766 boolean okay = roll && rename;
769 StringBuilder messageSB = new StringBuilder();
770 messageSB.append(MessageManager.getString(
771 "label.backupfiles_confirm_save_file_backupfiles_roll_wrong"));
772 // "Something possibly went wrong with the backups of this file."
775 if (messageSB.length() > 0)
777 messageSB.append("\n");
779 messageSB.append(MessageManager.getString(
780 "label.backupfiles_confirm_save_new_saved_file_ok"));
781 // "The new saved file seems okay."
785 if (messageSB.length() > 0)
787 messageSB.append("\n");
789 messageSB.append(MessageManager.getString(
790 "label.backupfiles_confirm_save_new_saved_file_not_ok"));
791 // "The new saved file might not be okay."
794 int confirmButton = Platform.isHeadless() ? JvOptionPane.OK_OPTION
795 : JvOptionPane.showConfirmDialog(Desktop.desktop,
796 messageSB.toString(),
797 MessageManager.getString(
798 "label.backupfiles_confirm_save_file"),
799 // "Confirm save file"
800 JvOptionPane.OK_OPTION, JvOptionPane.WARNING_MESSAGE);
801 okay = confirmButton == JvOptionPane.OK_OPTION;
811 public static TreeMap<Integer, File> getBackupFilesAsTreeMap(
812 String fileName, String suffix, int digits)
814 File[] backupFiles = null;
816 File file = new File(fileName);
821 dirFile = file.getParentFile();
822 } catch (Exception e)
825 "Could not get canonical path for file '" + file + "'");
826 return new TreeMap<>();
829 String filename = file.getName();
830 String basename = filename;
832 // find existing backup files
833 BackupFilenameFilter bff = new BackupFilenameFilter(basename, suffix,
835 backupFiles = dirFile.listFiles(bff); // is clone needed?
837 // sort the backup files (based on integer found in the suffix) using a
838 // precomputed Hashmap for speed
839 Map<Integer, File> bfHashMap = new HashMap<>();
840 for (int i = 0; i < backupFiles.length; i++)
842 File f = backupFiles[i];
843 BackupFilenameParts bfp = new BackupFilenameParts(f, basename, suffix,
845 bfHashMap.put(bfp.indexNum(), f);
847 TreeMap<Integer, File> bfTreeMap = new TreeMap<>();
848 bfTreeMap.putAll(bfHashMap);
854 private boolean addDeleteFile(File fileToBeDeleted, File originalFile,
855 boolean delete, boolean newer)
857 return addDeleteFile(fileToBeDeleted, originalFile, null, delete, newer);
860 private boolean addDeleteFile(File fileToBeDeleted)
863 int pos = deleteFiles.indexOf(fileToBeDeleted);
866 Cache.log.debug("BACKUPFILES not adding file "
867 + fileToBeDeleted.getAbsolutePath()
868 + " to the delete list (already at index" + pos + ")");
873 Cache.log.debug("BACKUPFILES adding file "
874 + fileToBeDeleted.getAbsolutePath() + " to the delete list");
875 deleteFiles.add(fileToBeDeleted);
880 public static boolean moveFileToFile(File oldFile, File newFile)
883 Path oldPath = Paths.get(oldFile.getAbsolutePath());
884 Path newPath = Paths.get(newFile.getAbsolutePath());
887 // delete destination file - not usually necessary but Just In Case...
888 Cache.log.debug("BACKUPFILES deleting " + newFile.getAbsolutePath());
890 Cache.log.debug("BACKUPFILES moving " + oldFile.getAbsolutePath()
891 + " to " + newFile.getAbsolutePath());
892 Files.move(oldPath, newPath, StandardCopyOption.REPLACE_EXISTING);
894 Cache.log.debug("BACKUPFILES move seemse to have succeeded");
895 } catch (IOException e)
897 Cache.log.warn("Could not move file '" + oldPath.toString() + "' to '"
898 + newPath.toString() + "'");
899 Cache.log.error(e.getMessage());
900 Cache.log.debug(e.getStackTrace());
902 } catch (Exception e)
904 Cache.log.error(e.getMessage());
905 Cache.log.debug(e.getStackTrace());