mistake ...

This commit is contained in:
Paddy Xu
2018-09-02 10:44:03 +03:00
parent 30c0c29d4a
commit eae3e300ef
4 changed files with 26 additions and 22 deletions

View File

@@ -19,6 +19,7 @@ using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using QuickLook.Common.ExtensionMethods;
using QuickLook.Common.Plugin; using QuickLook.Common.Plugin;
namespace QuickLook.Plugin.PluginInstaller namespace QuickLook.Plugin.PluginInstaller
@@ -29,6 +30,7 @@ namespace QuickLook.Plugin.PluginInstaller
public void Init() public void Init()
{ {
CleanupOldPlugins(App.UserPluginPath);
} }
public bool CanHandle(string path) public bool CanHandle(string path)
@@ -58,5 +60,23 @@ namespace QuickLook.Plugin.PluginInstaller
public void Cleanup() 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
}
});
}
} }
} }

View File

@@ -72,6 +72,7 @@ namespace QuickLook.Plugin.PluginInstaller
catch (Exception ex) catch (Exception ex)
{ {
Dispatcher.BeginInvoke(new Action(() => description.Text = ex.Message)); Dispatcher.BeginInvoke(new Action(() => description.Text = ex.Message));
Dispatcher.BeginInvoke(new Action(() => btnInstall.Content = "Installation failed."));
CleanUp(); CleanUp();
} }
}); });
@@ -87,11 +88,13 @@ namespace QuickLook.Plugin.PluginInstaller
try try
{ {
Directory.GetFiles(targetFolder, "*", SearchOption.AllDirectories) 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) catch (Exception ex)
{ {
Dispatcher.BeginInvoke(new Action(() => description.Text = ex.Message)); Dispatcher.BeginInvoke(new Action(() => description.Text = ex.Message));
Dispatcher.BeginInvoke(new Action(() => btnInstall.Content = "Installation failed."));
} }
} }
} }

View File

@@ -81,7 +81,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\QuickLook.Common\QuickLook.Common.csproj"> <ProjectReference Include="..\..\QuickLook.Common\QuickLook.Common.csproj">
<Project>{85FDD6BA-871D-46C8-BD64-F6BB0CB5EA95}</Project> <Project>{85fdd6ba-871d-46c8-bd64-f6bb0cb5ea95}</Project>
<Name>QuickLook.Common</Name> <Name>QuickLook.Common</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </ProjectReference>

View File

@@ -33,7 +33,6 @@ namespace QuickLook
private PluginManager() private PluginManager()
{ {
CleanupOldPlugins(App.UserPluginPath);
LoadPlugins(App.UserPluginPath); LoadPlugins(App.UserPluginPath);
LoadPlugins(Path.Combine(App.AppPath, "QuickLook.Plugin\\")); LoadPlugins(Path.Combine(App.AppPath, "QuickLook.Plugin\\"));
InitLoadedPlugins(); 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
}
});
}
} }
} }