*/
package org.sonar.server.plugins;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
public final class PluginDeployer implements ServerComponent {
private static final Logger LOG = LoggerFactory.getLogger(PluginDeployer.class);
Collection<File> jars = FileUtils.listFiles(fileSystem.getDownloadedPluginsDir(), new String[] { "jar" }, false);
for (File jar : jars) {
File movedJar = moveDownloadedFile(jar);
- registerPluginMetadata(movedJar, false, true);
+ if (movedJar != null) {
+ registerPluginMetadata(movedJar, false, true);
+ }
}
}
}
if (destFile.exists()) {
// plugin with same filename already installed
FileUtils.deleteQuietly(jar);
- return destFile;
+ return null;
}
try {
FileUtils.moveFileToDirectory(jar, destDir, true);
- return new File(destDir, jar.getName());
+ return destFile;
} catch (IOException e) {
LOG.error("Fail to move the downloaded file: " + jar.getAbsolutePath(), e);