Plugins: Automatic detection of site plugins fails to copy over the content to `_site`

closes #3707
This commit is contained in:
Shay Banon 2013-09-16 18:12:34 +02:00
parent fd4ab5c3dc
commit e271177554
1 changed files with 11 additions and 7 deletions

View File

@ -132,7 +132,7 @@ public class PluginManager {
if (!downloaded) { if (!downloaded) {
// We try all possible locations // We try all possible locations
for (URL url: pluginHandle.urls()) { for (URL url : pluginHandle.urls()) {
log("Trying " + url.toExternalForm() + "..."); log("Trying " + url.toExternalForm() + "...");
try { try {
downloadHelper.download(url, pluginFile, progress); downloadHelper.download(url, pluginFile, progress);
@ -154,7 +154,7 @@ public class PluginManager {
//we check whether we need to remove the top-level folder while extracting //we check whether we need to remove the top-level folder while extracting
//sometimes (e.g. github) the downloaded archive contains a top-level folder which needs to be removed //sometimes (e.g. github) the downloaded archive contains a top-level folder which needs to be removed
boolean removeTopLevelDir = topLevelDirInExcess(zipFile); boolean removeTopLevelDir = topLevelDirInExcess(zipFile);
Enumeration <? extends ZipEntry> zipEntries = zipFile.entries(); Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
while (zipEntries.hasMoreElements()) { while (zipEntries.hasMoreElements()) {
ZipEntry zipEntry = zipEntries.nextElement(); ZipEntry zipEntry = zipEntries.nextElement();
if (zipEntry.isDirectory()) { if (zipEntry.isDirectory()) {
@ -204,10 +204,14 @@ public class PluginManager {
if (!FileSystemUtils.hasExtensions(extractLocation, ".class", ".jar")) { if (!FileSystemUtils.hasExtensions(extractLocation, ".class", ".jar")) {
log("Identified as a _site plugin, moving to _site structure ..."); log("Identified as a _site plugin, moving to _site structure ...");
File site = new File(extractLocation, "_site"); File site = new File(extractLocation, "_site");
File tmpLocation = new File(environment.pluginsFile(), name + ".tmp"); File tmpLocation = new File(environment.pluginsFile(), extractLocation.getName() + ".tmp");
extractLocation.renameTo(tmpLocation); if (!extractLocation.renameTo(tmpLocation)) {
throw new IOException("failed to rename in order to copy to _site (rename to " + tmpLocation.getAbsolutePath() + "");
}
FileSystemUtils.mkdirs(extractLocation); FileSystemUtils.mkdirs(extractLocation);
tmpLocation.renameTo(site); if (!tmpLocation.renameTo(site)) {
throw new IOException("failed to rename in order to copy to _site (rename to " + site.getAbsolutePath() + "");
}
debug("Installed " + name + " into " + site.getAbsolutePath()); debug("Installed " + name + " into " + site.getAbsolutePath());
} }
} }
@ -270,7 +274,7 @@ public class PluginManager {
int slash = zipEntryName.indexOf('/'); int slash = zipEntryName.indexOf('/');
//if there isn't a slash in the entry name it means that we have a file in the top-level //if there isn't a slash in the entry name it means that we have a file in the top-level
if (slash == -1 ) { if (slash == -1) {
return false; return false;
} }