mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add exception handles
This commit is contained in:
parent
66228151ae
commit
fe86e23dea
1 changed files with 27 additions and 7 deletions
|
|
@ -193,26 +193,46 @@ namespace Flow.Launcher.Plugin.Program
|
|||
{
|
||||
Helper.ValidateDirectory(Context.CurrentPluginMetadata.PluginCacheDirectoryPath);
|
||||
|
||||
static bool MoveFile(string sourcePath, string destinationPath)
|
||||
static void MoveFile(string sourcePath, string destinationPath)
|
||||
{
|
||||
if (!File.Exists(sourcePath))
|
||||
{
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (File.Exists(destinationPath))
|
||||
{
|
||||
File.Delete(sourcePath);
|
||||
return false;
|
||||
try
|
||||
{
|
||||
File.Delete(sourcePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore, we will handle next time we start the plugin
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var destinationDirectory = Path.GetDirectoryName(destinationPath);
|
||||
if (!Directory.Exists(destinationDirectory) && (!string.IsNullOrEmpty(destinationDirectory)))
|
||||
{
|
||||
Directory.CreateDirectory(destinationDirectory);
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(destinationDirectory);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore, we will handle next time we start the plugin
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
File.Move(sourcePath, destinationPath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore, we will handle next time we start the plugin
|
||||
}
|
||||
File.Move(sourcePath, destinationPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Move old cache files to the new cache directory
|
||||
|
|
|
|||
Loading…
Reference in a new issue