diff --git a/SparkleLib/Git/SparkleRepoGit.cs b/SparkleLib/Git/SparkleRepoGit.cs index 96caf38d..4af6e93f 100644 --- a/SparkleLib/Git/SparkleRepoGit.cs +++ b/SparkleLib/Git/SparkleRepoGit.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.IO; using System.Text; using System.Text.RegularExpressions; +using System.Threading; using SparkleLib; @@ -29,6 +30,7 @@ namespace SparkleLib.Git { private bool user_is_set; private bool use_git_bin; + private bool is_encrypted; public SparkleRepo (string path, SparkleConfig config) : base (path, config) @@ -50,6 +52,11 @@ namespace SparkleLib.Git { git = new SparkleGit (LocalPath, "rebase --abort"); git.StartAndWaitForExit (); } + + string password_file_path = Path.Combine (LocalPath, ".git", "password"); + + if (File.Exists (password_file_path)) + this.is_encrypted = true; } @@ -548,14 +555,46 @@ namespace SparkleLib.Git { throw new ArgumentNullException ("revision"); path = path.Replace ("\\", "/"); + SparkleLogger.LogInfo ("Git", Name + " | Restoring \"" + path + "\" (revision " + revision + ")"); - SparkleGit git = new SparkleGit (LocalPath, "checkout " + revision + " \"" + path + "\""); - git.StartAndWaitForExit (); + // FIXME: git-show doesn't decrypt objects, so we can't use it to retrieve + // files from the index. This is a suboptimal workaround but it does the job + if (this.is_encrypted) { + // Restore the older file... + SparkleGit git = new SparkleGit (LocalPath, "checkout " + revision + " \"" + path + "\""); + git.StartAndWaitForExit (); - if (git.ExitCode == 0) - SparkleLogger.LogInfo ("Git", Name + " | Checked out \"" + path + "\" (" + revision + ")"); - else - SparkleLogger.LogInfo ("Git", Name + " | Failed to check out \"" + path + "\" (" + revision + ")"); + string local_file_path = Path.Combine (LocalPath, path); + + // ...move it... + try { + File.Move (local_file_path, target_file_path); + + } catch { + SparkleLogger.LogInfo ("Git", + Name + " | Could not move \"" + local_file_path + "\" to \"" + target_file_path + "\""); + } + + // ...and restore the most recent revision + git = new SparkleGit (LocalPath, "checkout " + CurrentRevision + " \"" + path + "\""); + git.StartAndWaitForExit (); + + // The correct way + } else { + path = path.Replace (" ", "\\ "); + + SparkleGit git = new SparkleGit (LocalPath, "show " + revision + ":" + path + ""); + git.Start (); + + FileStream stream = File.OpenWrite (target_file_path); + git.StandardOutput.BaseStream.CopyTo (stream); + stream.Close (); + + git.WaitForExit (); + } + + if (target_file_path.StartsWith (LocalPath)) + new Thread (() => OnFileActivity (null)).Start (); } diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index 4c0e4ec3..4ccf85fe 100755 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -218,9 +218,11 @@ namespace SparkleLib { if (IsBuffering) return; - foreach (string exclude_path in ExcludePaths) { - if (args.FullPath.Contains (exclude_path)) - return; + if (args != null) { + foreach (string exclude_path in ExcludePaths) { + if (args.FullPath.Contains (exclude_path)) + return; + } } lock (this.buffer_lock) { diff --git a/SparkleShare/Mac/SparkleEventLog.cs b/SparkleShare/Mac/SparkleEventLog.cs index cdf4fe48..92f36b7f 100755 --- a/SparkleShare/Mac/SparkleEventLog.cs +++ b/SparkleShare/Mac/SparkleEventLog.cs @@ -252,10 +252,13 @@ namespace SparkleShare { PreventsApplicationTerminationWhenModal = false }; - if ((NSPanelButtonType) panel.RunModal ()== NSPanelButtonType.Ok) - Controller.SaveDialogCompleted ("f"); - else + if ((NSPanelButtonType) panel.RunModal ()== NSPanelButtonType.Ok) { + string target_file_path = Path.Combine (panel.DirectoryUrl.RelativePath, panel.NameFieldStringValue); + Controller.SaveDialogCompleted (target_file_path); + + } else { Controller.SaveDialogCancelled (); + } }); } }; diff --git a/SparkleShare/SparkleEventLogController.cs b/SparkleShare/SparkleEventLogController.cs index 67540d09..f5ae2563 100755 --- a/SparkleShare/SparkleEventLogController.cs +++ b/SparkleShare/SparkleEventLogController.cs @@ -253,6 +253,8 @@ namespace SparkleShare { } else if (url.StartsWith ("history://")) { + UpdateSizeInfoEvent ("…", "…"); + string html = ""; string folder = url.Replace ("history://", "").Split ("/".ToCharArray ()) [0]; string path = url.Replace ("history://" + folder + "/", ""); @@ -305,7 +307,6 @@ namespace SparkleShare { } } - UpdateContentEvent (Program.Controller.EventLogHTML.Replace ("", html)); } } @@ -323,6 +324,7 @@ namespace SparkleShare { } this.restore_revision_info = null; + Program.Controller.OpenFolder (Path.GetDirectoryName (target_file_path)); }