Skip to content

Commit

Permalink
Merge pull request #4417 from DanielBoudreau/master
Browse files Browse the repository at this point in the history
Fix switch list bug when running in consolidation mode
  • Loading branch information
bobjacobsen committed Nov 12, 2017
2 parents 4d385d1 + a23af82 commit f819936
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion java/src/jmri/jmrit/operations/setup/PrintOptionPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import javax.swing.colorchooser.AbstractColorChooserPanel;
import jmri.InstanceManager;
import jmri.jmrit.operations.trains.TrainManager;
import jmri.util.ColorUtil;
import jmri.util.FileUtil;
import jmri.util.swing.ButtonSwatchColorChooserPanel;
import jmri.util.swing.FontComboUtil;
Expand Down
3 changes: 0 additions & 3 deletions java/src/jmri/jmrit/operations/setup/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import javax.swing.JColorChooser;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.JComboBox;
import jmri.Disposable;
import jmri.InstanceManager;
Expand All @@ -16,7 +14,6 @@
import jmri.jmrit.operations.trains.TrainLogger;
import jmri.jmrit.operations.trains.TrainManagerXml;
import jmri.util.ColorUtil;
import jmri.util.swing.ButtonSwatchColorChooserPanel;
import jmri.web.server.WebServerPreferences;
import org.jdom2.Element;
import org.slf4j.Logger;
Expand Down
12 changes: 7 additions & 5 deletions java/src/jmri/jmrit/operations/trains/TrainManagerXml.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void writeFile(String name) throws java.io.FileNotFoundException, java.io
Document doc = newDocument(root, dtdLocation + "operations-trains.dtd"); // NOI18N

// add XSLT processing instruction
java.util.Map<String, String> m = new java.util.HashMap<String, String>();
java.util.Map<String, String> m = new java.util.HashMap<>();
m.put("type", "text/xsl"); // NOI18N
m.put("href", xsltLocation + "operations-trains.xsl"); // NOI18N
ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m); // NOI18N
Expand Down Expand Up @@ -388,12 +388,14 @@ private void savePreviousSwitchListFile(String name) {
File file = findFile(getDefaultSwitchListName(name));
if (file == null) {
log.debug("No ({}) switch list file to backup", name);
} else if (file.canWrite()) {
} else if (file.canRead()) {
String lastModified = new SimpleDateFormat("yyyyMMdd-HHmmss").format(file.lastModified()); // NOI18N
String backupName = getBackupSwitchListFileName(name, lastModified); // NOI18N
if (file.renameTo(new File(backupName))) {
log.debug("created new switch list backup file {}", backupName);
} else {
File backupCopy = new File(backupName);
try {
FileUtil.copy(file, backupCopy);
log.debug("created new switch list backup file {}", backupName);
} catch (Exception e) {
log.error("could not create switch list backup file {}", backupName);
}
}
Expand Down

0 comments on commit f819936

Please sign in to comment.