Skip to content
Permalink
Browse files

[JENKINS-41124] Additional tracking of legacy name

  • Loading branch information...
stephenc committed Jan 20, 2017
1 parent 93e075a commit b2e6e88f51cf1bead3b57492b933a3c88c06a818
Showing with 20 additions and 9 deletions.
  1. +20 −9 src/main/java/com/cloudbees/hudson/plugins/folder/AbstractFolder.java
@@ -534,12 +534,12 @@ public boolean accept(File child) {
}
// Try to retain the identity of an existing child object if we can.
V item = byDirName.get(childName);
boolean itemNeedsSave = false;
if (item == null) {
XmlFile xmlFile = Items.getConfigFile(subdir);
if (xmlFile.exists()) {
item = (V) xmlFile.read();
String name;
boolean itemNeedsSave = false;
if (childNameGenerator == null) {
name = subdir.getName();
} else {
@@ -595,14 +595,6 @@ public boolean accept(File child) {
}
}
item.onLoad(parent, name);
if (itemNeedsSave) {
try {
item.save();
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Could not update {0} after applying folder naming rules",
item.getFullName());
}
}
} else {
Logger.getLogger(AbstractFolder.class.getName())
.log(Level.WARNING, "could not find file " + xmlFile.getFile());
@@ -618,6 +610,17 @@ public boolean accept(File child) {
if (name == null) {
name = childNameGenerator.itemNameFromLegacy(parent, childName);
FileUtils.writeStringToFile(nameFile, name, "UTF-8");
BulkChange bc = new BulkChange(item); // suppress any attempt to save as parent not set
try {
childNameGenerator.recordLegacyName(parent, item, childName);
itemNeedsSave = true;
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Ignoring {0} as could not record legacy name",
subdir);
continue;
} finally {
bc.abort();
}
} else if (!childName.equals(name) || legacy) {
FileUtils.writeStringToFile(nameFile, name, "UTF-8");
}
@@ -633,6 +636,14 @@ public boolean accept(File child) {
}
item.onLoad(parent, name);
}
if (itemNeedsSave) {
try {
item.save();
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Could not update {0} after applying folder naming rules",
item.getFullName());
}
}
configurations.put(key.call(item), item);
} catch (Exception e) {
Logger.getLogger(ItemGroupMixIn.class.getName()).log(Level.WARNING, "could not load " + subdir, e);

0 comments on commit b2e6e88

Please sign in to comment.
You can’t perform that action at this time.