diff --git a/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/Plugin.cs index 5bb906a..20b3c37 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/Plugin.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/Plugin.cs @@ -19,6 +19,7 @@ using System; using System.IO; using System.Linq; using System.Windows; +using QuickLook.Common.ExtensionMethods; using QuickLook.Common.Plugin; namespace QuickLook.Plugin.PluginInstaller @@ -29,6 +30,7 @@ namespace QuickLook.Plugin.PluginInstaller public void Init() { + CleanupOldPlugins(App.UserPluginPath); } public bool CanHandle(string path) @@ -58,5 +60,23 @@ namespace QuickLook.Plugin.PluginInstaller public void Cleanup() { } + + private static void CleanupOldPlugins(string folder) + { + if (!Directory.Exists(folder)) + return; + + Directory.GetFiles(folder, "*.to_be_deleted", SearchOption.AllDirectories).ForEach(file => + { + try + { + File.Delete(file); + } + catch (Exception) + { + // ignored + } + }); + } } } \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/PluginInfoPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/PluginInfoPanel.xaml.cs index fe73360..db9e458 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/PluginInfoPanel.xaml.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/PluginInfoPanel.xaml.cs @@ -52,7 +52,7 @@ namespace QuickLook.Plugin.PluginInstaller btnInstall.Content = "Installing ..."; btnInstall.IsEnabled = false; - var t=DoInstall(); + var t = DoInstall(); t.ContinueWith(_ => Dispatcher.BeginInvoke(new Action(() => btnInstall.Content = "Done! Please restart QuickLook."))); t.Start(); @@ -72,6 +72,7 @@ namespace QuickLook.Plugin.PluginInstaller catch (Exception ex) { Dispatcher.BeginInvoke(new Action(() => description.Text = ex.Message)); + Dispatcher.BeginInvoke(new Action(() => btnInstall.Content = "Installation failed.")); CleanUp(); } }); @@ -87,11 +88,13 @@ namespace QuickLook.Plugin.PluginInstaller try { Directory.GetFiles(targetFolder, "*", SearchOption.AllDirectories) - .ForEach(file => File.Move(file, new Guid() + ".to_be_deleted")); + .ForEach(file => File.Move(file, + Path.Combine(Path.GetDirectoryName(file), Guid.NewGuid() + ".to_be_deleted"))); } catch (Exception ex) { Dispatcher.BeginInvoke(new Action(() => description.Text = ex.Message)); + Dispatcher.BeginInvoke(new Action(() => btnInstall.Content = "Installation failed.")); } } } diff --git a/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/QuickLook.Plugin.PluginInstaller.csproj b/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/QuickLook.Plugin.PluginInstaller.csproj index 25dca7d..990d1e8 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/QuickLook.Plugin.PluginInstaller.csproj +++ b/QuickLook.Plugin/QuickLook.Plugin.PluginInstaller/QuickLook.Plugin.PluginInstaller.csproj @@ -81,7 +81,7 @@ - {85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95} + {85fdd6ba-871d-46c8-bd64-f6bb0cb5ea95} QuickLook.Common False diff --git a/QuickLook/PluginManager.cs b/QuickLook/PluginManager.cs index d465dc8..26c3c4e 100644 --- a/QuickLook/PluginManager.cs +++ b/QuickLook/PluginManager.cs @@ -33,7 +33,6 @@ namespace QuickLook private PluginManager() { - CleanupOldPlugins(App.UserPluginPath); LoadPlugins(App.UserPluginPath); LoadPlugins(Path.Combine(App.AppPath, "QuickLook.Plugin\\")); InitLoadedPlugins(); @@ -113,23 +112,5 @@ namespace QuickLook } }); } - - private static void CleanupOldPlugins(string folder) - { - if (!Directory.Exists(folder)) - return; - - Directory.GetFiles(folder, "*.to_be_deleted", SearchOption.AllDirectories).ForEach(file => - { - try - { - File.Delete(file); - } - catch (Exception) - { - // ignored - } - }); - } } } \ No newline at end of file