controller: Move cloned folder deletion logic to fetcher

This commit is contained in:
Hylke Bons 2013-06-30 15:48:35 +01:00
parent 8cf594039f
commit b4fabcf944
2 changed files with 16 additions and 16 deletions

View file

@ -254,10 +254,8 @@ namespace SparkleLib.Git {
return false; return false;
} }
Process process = new Process () { Process process = new Process ();
EnableRaisingEvents = true process.EnableRaisingEvents = true;
};
process.StartInfo.WorkingDirectory = TargetFolder; process.StartInfo.WorkingDirectory = TargetFolder;
process.StartInfo.UseShellExecute = false; process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardOutput = true;
@ -267,6 +265,9 @@ namespace SparkleLib.Git {
process.StartInfo.Arguments = "enc -d -aes-256-cbc -base64 -S " + this.crypto_salt + process.StartInfo.Arguments = "enc -d -aes-256-cbc -base64 -S " + this.crypto_salt +
" -pass pass:\"" + password + "\" -in " + password_check_file_path; " -pass pass:\"" + password + "\" -in " + password_check_file_path;
SparkleLogger.LogInfo ("Cmd | " + System.IO.Path.GetFileName (process.StartInfo.WorkingDirectory),
System.IO.Path.GetFileName (process.StartInfo.FileName) + " " + process.StartInfo.Arguments);
process.Start (); process.Start ();
process.WaitForExit (); process.WaitForExit ();
@ -291,6 +292,16 @@ namespace SparkleLib.Git {
} catch (Exception e) { } catch (Exception e) {
SparkleLogger.LogInfo ("Fetcher", "Failed to dispose properly", e); SparkleLogger.LogInfo ("Fetcher", "Failed to dispose properly", e);
} }
if (Directory.Exists (TargetFolder)) {
try {
Directory.Delete (TargetFolder, true /* Recursive */ );
SparkleLogger.LogInfo ("Fetcher", "Deleted '" + TargetFolder + "'");
} catch (Exception e) {
SparkleLogger.LogInfo ("Fetcher", "Failed to delete '" + TargetFolder + "'", e);
}
}
} }

View file

@ -588,20 +588,9 @@ namespace SparkleShare {
public void StopFetcher () public void StopFetcher ()
{ {
this.fetcher.Stop (); this.fetcher.Stop ();
if (Directory.Exists (this.fetcher.TargetFolder)) {
try {
Directory.Delete (this.fetcher.TargetFolder, true /* Recursive */ );
SparkleLogger.LogInfo ("Controller", "Deleted '" + this.fetcher.TargetFolder + "'");
} catch (Exception e) {
SparkleLogger.LogInfo ("Controller", "Failed to delete '" + this.fetcher.TargetFolder + "'", e);
}
}
this.fetcher.Dispose (); this.fetcher.Dispose ();
this.fetcher = null;
this.fetcher = null;
this.watcher.EnableRaisingEvents = true; this.watcher.EnableRaisingEvents = true;
} }