提交 7937b2bf 编写于 作者: O Olivier Lamy

Merge pull request #1173 from olamy/not-try-to-load-non-existing-files-improved

improve a bit previous commit
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
package hudson.model; package hudson.model;
import hudson.Util; import hudson.Util;
import hudson.XmlFile;
import hudson.model.listeners.ItemListener; import hudson.model.listeners.ItemListener;
import hudson.remoting.Callable; import hudson.remoting.Callable;
import hudson.security.AccessControlled; import hudson.security.AccessControlled;
...@@ -93,7 +94,7 @@ public abstract class ItemGroupMixIn { ...@@ -93,7 +94,7 @@ public abstract class ItemGroupMixIn {
File[] subdirs = modulesDir.listFiles(new FileFilter() { File[] subdirs = modulesDir.listFiles(new FileFilter() {
public boolean accept(File child) { public boolean accept(File child) {
return child.isDirectory() && new File(child,"config.xml").exists(); return child.isDirectory();
} }
}); });
CopyOnWriteMap.Tree<K,V> configurations = new CopyOnWriteMap.Tree<K,V>(); CopyOnWriteMap.Tree<K,V> configurations = new CopyOnWriteMap.Tree<K,V>();
...@@ -102,7 +103,12 @@ public abstract class ItemGroupMixIn { ...@@ -102,7 +103,12 @@ public abstract class ItemGroupMixIn {
// Try to retain the identity of an existing child object if we can. // Try to retain the identity of an existing child object if we can.
V item = (V) parent.getItem(subdir.getName()); V item = (V) parent.getItem(subdir.getName());
if (item == null) { if (item == null) {
item = (V) Items.load(parent,subdir); XmlFile xmlFile = Items.getConfigFile( subdir );
if (xmlFile.exists()) {
item = (V) Items.load( parent, subdir );
}else{
Logger.getLogger( ItemGroupMixIn.class.getName() ).log( Level.WARNING, "could not find file " + xmlFile.getFile());
}
} else { } else {
item.onLoad(parent, subdir.getName()); item.onLoad(parent, subdir.getName());
} }
......
...@@ -42,6 +42,8 @@ import org.apache.commons.lang.StringUtils; ...@@ -42,6 +42,8 @@ import org.apache.commons.lang.StringUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull; import javax.annotation.CheckForNull;
import jenkins.model.DirectlyModifiableTopLevelItemGroup; import jenkins.model.DirectlyModifiableTopLevelItemGroup;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册