mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Update with exception handling and continue
This commit is contained in:
parent
ad4c9fb4ef
commit
ba46ce09dc
1 changed files with 37 additions and 24 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
namespace Wox.Plugin.SharedCommands
|
namespace Wox.Plugin.SharedCommands
|
||||||
{
|
{
|
||||||
|
|
@ -16,26 +18,38 @@ namespace Wox.Plugin.SharedCommands
|
||||||
+ sourcePath);
|
+ sourcePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectoryInfo[] dirs = dir.GetDirectories();
|
try
|
||||||
// If the destination directory doesn't exist, create it.
|
|
||||||
if (!Directory.Exists(targetPath))
|
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(targetPath);
|
DirectoryInfo[] dirs = dir.GetDirectories();
|
||||||
}
|
// If the destination directory doesn't exist, create it.
|
||||||
|
if (!Directory.Exists(targetPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(targetPath);
|
||||||
|
}
|
||||||
|
|
||||||
// Get the files in the directory and copy them to the new location.
|
// Get the files in the directory and copy them to the new location.
|
||||||
FileInfo[] files = dir.GetFiles();
|
FileInfo[] files = dir.GetFiles();
|
||||||
foreach (FileInfo file in files)
|
foreach (FileInfo file in files)
|
||||||
{
|
{
|
||||||
string temppath = Path.Combine(targetPath, file.Name);
|
string temppath = Path.Combine(targetPath, file.Name);
|
||||||
file.CopyTo(temppath, false);
|
file.CopyTo(temppath, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursively copy subdirectories by calling itself on each subdirectory until there are no more to copy
|
// Recursively copy subdirectories by calling itself on each subdirectory until there are no more to copy
|
||||||
foreach (DirectoryInfo subdir in dirs)
|
foreach (DirectoryInfo subdir in dirs)
|
||||||
|
{
|
||||||
|
string temppath = Path.Combine(targetPath, subdir.Name);
|
||||||
|
Copy(subdir.FullName, temppath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
string temppath = Path.Combine(targetPath, subdir.Name);
|
#if DEBUG
|
||||||
Copy(subdir.FullName, temppath);
|
throw e;
|
||||||
|
#else
|
||||||
|
MessageBox.Show(string.Format("Copying path {0} has failed, it will now be deleted for consistency", targetPath));
|
||||||
|
RemoveFolder(targetPath);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -55,11 +69,12 @@ namespace Wox.Plugin.SharedCommands
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(PathTooLongException e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
throw;
|
throw e;
|
||||||
#else
|
#else
|
||||||
|
MessageBox.Show(string.Format("Unable to verify folders and files between {0} and {1}", fromPath, toPath));
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -73,14 +88,12 @@ namespace Wox.Plugin.SharedCommands
|
||||||
if (Directory.Exists(path))
|
if (Directory.Exists(path))
|
||||||
Directory.Delete(path, true);
|
Directory.Delete(path, true);
|
||||||
}
|
}
|
||||||
catch(PathTooLongException e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
//log and update error message to output
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
throw;
|
throw e;
|
||||||
#else
|
#else
|
||||||
throw;// PRODUCTION LOGGING AND CONTINUE
|
MessageBox.Show(string.Format("Not able to delete folder {0}, please go to the location and manually delete it", path));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue