Use folders_path config option to create the tmo dir when it is set. Fixes #485

This commit is contained in:
Hylke Bons 2011-12-18 17:10:06 +01:00
parent 99c148883e
commit c235248078
4 changed files with 26 additions and 21 deletions

View file

@ -83,14 +83,14 @@ namespace SparkleLib {
public override bool Fetch () public override bool Fetch ()
{ {
this.git = new SparkleGit (SparkleConfig.DefaultConfig.TmpPath, this.git = new SparkleGit (base.target_folder,
"clone " + "clone " +
"--progress " + // Redirects progress stats to standarderror "--progress " + // Redirects progress stats to standarderror
"\"" + base.remote_url + "\" " + "\"" + base.target_folder + "\""); "\"" + base.remote_url + "\" " + "\"" + base.target_folder + "\"");
this.git.StartInfo.RedirectStandardError = true; this.git.StartInfo.RedirectStandardError = true;
this.git.Start (); this.git.Start ();
double percentage = 1.0; double percentage = 1.0;
Regex progress_regex = new Regex (@"([0-9]+)%", RegexOptions.Compiled); Regex progress_regex = new Regex (@"([0-9]+)%", RegexOptions.Compiled);
@ -270,6 +270,7 @@ namespace SparkleLib {
} }
} }
public class SparkleGit : Process { public class SparkleGit : Process {
public SparkleGit (string path, string args) : base () public SparkleGit (string path, string args) : base ()

View file

@ -33,11 +33,9 @@ namespace SparkleLib {
public static SparkleConfig DefaultConfig = new SparkleConfig (ConfigPath, "config.xml"); public static SparkleConfig DefaultConfig = new SparkleConfig (ConfigPath, "config.xml");
public string FullPath; public string FullPath;
public string HomePath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); public string HomePath = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
public string TmpPath;
public string FoldersPath { public string FoldersPath {
get { get {
@ -48,11 +46,16 @@ namespace SparkleLib {
} }
} }
public string TmpPath {
get {
return Path.Combine (FoldersPath, ".tmp");
}
}
public SparkleConfig (string config_path, string config_file_name) public SparkleConfig (string config_path, string config_file_name)
{ {
FullPath = System.IO.Path.Combine (config_path, config_file_name); FullPath = System.IO.Path.Combine (config_path, config_file_name);
TmpPath = Path.Combine (FoldersPath, ".tmp");
if (!Directory.Exists (config_path)) { if (!Directory.Exists (config_path)) {
Directory.CreateDirectory (config_path); Directory.CreateDirectory (config_path);

View file

@ -162,7 +162,7 @@ namespace SparkleLib {
//file_info.FileAccessPermissions = (FileAccessPermissions.UserRead | //file_info.FileAccessPermissions = (FileAccessPermissions.UserRead |
// FileAccessPermissions.UserWrite); TODO // FileAccessPermissions.UserWrite); TODO
SparkleHelpers.DebugInfo ("Fetcher", "Disabled host key checking " + host); SparkleHelpers.DebugInfo ("Fetcher", "Disabled host key checking for " + host);
} }

View file

@ -992,23 +992,24 @@ namespace SparkleShare {
try { try {
Directory.Move (tmp_folder, target_folder_path); Directory.Move (tmp_folder, target_folder_path);
SparkleConfig.DefaultConfig.AddFolder (target_folder_name, this.fetcher.RemoteUrl, backend);
AddRepository (target_folder_path);
if (FolderFetched != null)
FolderFetched (warnings);
if (FolderListChanged != null)
FolderListChanged ();
this.fetcher.Dispose ();
if (Directory.Exists (tmp_path))
Directory.Delete (tmp_path, true);
} catch (Exception e) { } catch (Exception e) {
SparkleHelpers.DebugInfo ("Controller", "Error moving folder: " + e.Message); SparkleHelpers.DebugInfo ("Controller", "Error moving folder: " + e.Message);
} }
SparkleConfig.DefaultConfig.AddFolder (target_folder_name, this.fetcher.RemoteUrl, backend);
AddRepository (target_folder_path);
if (FolderFetched != null)
FolderFetched (warnings);
if (FolderListChanged != null)
FolderListChanged ();
this.fetcher.Dispose ();
if (Directory.Exists (tmp_path))
Directory.Delete (tmp_path, true);
}; };