Skip to content

Commit

Permalink
Refresh plugins when downloading a new one.
Browse files Browse the repository at this point in the history
Don't try to add it based on path, just get the PluginManager
to refresh everything.
  • Loading branch information
csmith committed Feb 3, 2015
1 parent e8aec4d commit 93ba059
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

package com.dmdirc.addons.ui_swing.components.addonbrowser;

import com.dmdirc.DMDircMBassador;
import com.dmdirc.addons.ui_swing.components.LoggingSwingWorker;
import com.dmdirc.plugins.PluginManager;
import com.dmdirc.util.io.Downloader;
Expand Down Expand Up @@ -59,7 +58,6 @@ public InstallWorker(
final String pluginDirectory,
final String themeDirectory,
final PluginManager pluginManager,
final DMDircMBassador eventBus,
final AddonInfo info,
final InstallerWindow window) {
this.downloader = downloader;
Expand All @@ -82,18 +80,18 @@ protected String doInBackground() {
final Path newFile = Paths.get(pluginDirectory, info.getTitle() + ".jar");
try {
Files.move(file, newFile);
pluginManager.addPlugin(newFile.getFileName().toString());
pluginManager.refreshPlugins();
} catch (IOException ex) {
return "Unable to install addon, failed to move file: "
+ file.toAbsolutePath().toString();
+ file.toAbsolutePath();
}
break;
case TYPE_THEME:
try {
Files.move(file, Paths.get(themeDirectory, info.getTitle() + ".zip"));
} catch (IOException ex) {
return "Unable to install addon, failed to move file: "
+ file.toAbsolutePath().toString();
+ file.toAbsolutePath();
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,40 @@

package com.dmdirc.addons.ui_swing.components.addonbrowser;

import com.dmdirc.DMDircMBassador;
import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
import com.dmdirc.plugins.PluginManager;
import com.dmdirc.util.io.Downloader;

import javax.inject.Inject;
import javax.inject.Singleton;

/**
* Factory for {@link InstallWorker}s.
*/
@Singleton
public class InstallWorkerFactory {

private final Downloader downloader;
private final String tempDirectory;
private final String pluginDirectory;
private final String themeDirectory;
private final PluginManager pluginManager;
private final DMDircMBassador eventBus;

@Inject
public InstallWorkerFactory(final Downloader downloader,
@Directory(DirectoryType.TEMPORARY) final String tempDirectory,
@Directory(DirectoryType.PLUGINS) final String pluginDirectory,
@Directory(DirectoryType.THEMES) final String themeDirectory,
final PluginManager pluginManager, final DMDircMBassador eventBus) {
final PluginManager pluginManager) {
this.downloader = downloader;
this.tempDirectory = tempDirectory;
this.pluginDirectory = pluginDirectory;
this.themeDirectory = themeDirectory;
this.pluginManager = pluginManager;
this.eventBus = eventBus;
}
public InstallWorker getInstallWorker(final AddonInfo info, final InstallerWindow installer) {
return new InstallWorker(downloader, tempDirectory, pluginDirectory,
themeDirectory, pluginManager, eventBus, info, installer);
themeDirectory, pluginManager, info, installer);
}
}

0 comments on commit 93ba059

Please sign in to comment.