Permalink
Browse files

fetcher: fix support for http(s) repos. closes #1000

  • Loading branch information...
1 parent 570c0eb commit a02bd278b0c58fded7f1d4bea89ff5d5f376fca0 @hbons committed Oct 5, 2012
@@ -77,7 +77,7 @@ public class SparkleFetcher : SparkleFetcherBase {
uri = new Uri ("ssh://" + uri);
}
- if (uri.Host.Equals ("gitorious.org")) {
+ if (uri.Host.Equals ("gitorious.org") && !uri.Scheme.StartsWith ("http")) {
if (!uri.AbsolutePath.Equals ("/") &&
!uri.AbsolutePath.EndsWith (".git")) {
@@ -87,20 +87,17 @@ public class SparkleFetcher : SparkleFetcherBase {
uri = new Uri ("ssh://git@gitorious.org" + uri.AbsolutePath);
}
- } else if (uri.Host.Equals ("github.com")) {
+ } else if (uri.Host.Equals ("github.com") && !uri.Scheme.StartsWith ("http")) {
uri = new Uri ("ssh://git@github.com" + uri.AbsolutePath);
- } else if (uri.Host.Equals ("bitbucket.org")) {
+ } else if (uri.Host.Equals ("bitbucket.org") && !uri.Scheme.StartsWith ("http")) {
// Nothing really
} else if (uri.Host.Equals ("gnome.org")) {
uri = new Uri ("ssh://git@gnome.org/git" + uri.AbsolutePath);
} else {
- if (string.IsNullOrEmpty (uri.UserInfo) &&
- !uri.Scheme.Equals ("https") &&
- !uri.Scheme.Equals ("http")) {
-
+ if (string.IsNullOrEmpty (uri.UserInfo) && !uri.Scheme.StartsWith ("http")) {
if (uri.Port == -1)
uri = new Uri (uri.Scheme + "://storage@" + uri.Host + uri.AbsolutePath);
else
@@ -296,9 +293,11 @@ public override bool IsFetchedRepoPasswordCorrect (string password)
public override void Stop ()
{
try {
- this.git.Close ();
- this.git.Kill ();
- this.git.Dispose ();
+ if (this.git != null) {
+ this.git.Close ();
+ this.git.Kill ();
+ this.git.Dispose ();
+ }
} catch (Exception e) {
SparkleLogger.LogInfo ("Fetcher", "Failed to dispose properly: " + e.Message);
@@ -122,45 +122,47 @@ public void Start ()
if (Directory.Exists (TargetFolder))
Directory.Delete (TargetFolder, true);
- string host = RemoteUrl.Host;
- string host_key = GetHostKey ();
+ string host_key = "";
- if (string.IsNullOrEmpty (host) || host_key == null) {
- Failed ();
- return;
- }
+ if (!RemoteUrl.Scheme.StartsWith ("http")) {
+ host_key = FetchHostKey ();
+
+ if (string.IsNullOrEmpty (RemoteUrl.Host) || host_key == null) {
+ Failed ();
+ return;
+ }
+
+ bool warn = true;
+ if (RequiredFingerprint != null) {
+ string host_fingerprint = GetFingerprint (host_key);
- bool warn = true;
- if (RequiredFingerprint != null) {
- string host_fingerprint = GetFingerprint (host_key);
+ if (host_fingerprint == null || !RequiredFingerprint.Equals (host_fingerprint)) {
+ SparkleLogger.LogInfo ("Auth", "Fingerprint doesn't match");
- if (host_fingerprint == null || !RequiredFingerprint.Equals (host_fingerprint)) {
- SparkleLogger.LogInfo ("Auth", "Fingerprint doesn't match");
+ this.errors.Add ("error: Host fingerprint doesn't match");
+ Failed ();
- this.errors.Add ("error: Host fingerprint doesn't match");
- Failed ();
+ return;
+ }
- return;
- }
+ warn = false;
+ SparkleLogger.LogInfo ("Auth", "Fingerprint matches");
- warn = false;
- SparkleLogger.LogInfo ("Auth", "Fingerprint matches");
+ } else {
+ SparkleLogger.LogInfo ("Auth", "Skipping fingerprint check");
+ }
- } else {
- SparkleLogger.LogInfo ("Auth", "Skipping fingerprint check");
+ AcceptHostKey (host_key, warn);
}
- AcceptHostKey (host_key, warn);
-
this.thread = new Thread (() => {
if (Fetch ()) {
Thread.Sleep (500);
SparkleLogger.LogInfo ("Fetcher", "Finished");
IsActive = false;
- // TODO: Find better way to determine if folder should have crypto setup
- bool repo_is_encrypted = RemoteUrl.ToString ().Contains ("-crypto");
+ bool repo_is_encrypted = RemoteUrl.AbsolutePath.Contains ("-crypto");
Finished (repo_is_encrypted, IsFetchedRepoEmpty, Warnings);
} else {
@@ -206,7 +208,7 @@ private void CreateInitialChangeSet ()
uri_builder.Password = "";
}
- bool repo_is_encrypted = RemoteUrl.ToString ().Contains ("-crypto");
+ bool repo_is_encrypted = RemoteUrl.AbsolutePath.Contains ("-crypto");
string text;
if (repo_is_encrypted) {
@@ -235,6 +237,7 @@ public static string CreateIdentifier ()
return random.SHA1 ();
}
+
public void Dispose ()
{
if (this.thread != null)
@@ -254,7 +257,7 @@ protected string GenerateCryptoSalt ()
}
- private string GetHostKey ()
+ private string FetchHostKey ()
{
string host = RemoteUrl.Host;
int port = RemoteUrl.Port;
@@ -30,12 +30,10 @@
$('.show').each (function () {
var entry_count = $(this).parent ().find ('dl').children ().length;
- if (entry_count <= 10) {
- $(this).hide ();
- } else {
- // Append the number of entries
+ if (entry_count > 10)
$(this).html ('Show all ' + entry_count + '');
- }
+ else
+ $(this).hide ();
});
// When 'Show all' is clicked, show all collapsed events
@@ -432,7 +432,7 @@ public void OnFolderActivity (object o, FileSystemEventArgs args)
} else {
if (Directory.Exists (args.FullPath) && args.ChangeType == WatcherChangeTypes.Created)
return;
-
+
CheckRepositories ();
}
}
@@ -540,19 +540,20 @@ public void StopFetcher ()
} catch (Exception e) {
SparkleLogger.LogInfo ("Controller",
- "Failed to delete " + this.fetcher.TargetFolder + ": " + e.Message);
+ "Failed to delete '" + this.fetcher.TargetFolder + "': " + e.Message);
}
}
this.fetcher.Dispose ();
this.fetcher = null;
+
+ this.watcher.EnableRaisingEvents = true;
}
public void FinishFetcher (string password)
{
this.fetcher.EnableFetchedRepoCrypto (password);
-
FinishFetcher ();
}
@@ -590,6 +591,7 @@ public void FinishFetcher ()
} catch (Exception e) {
SparkleLogger.LogInfo ("Controller", "Error moving directory: " + e.Message);
+ this.watcher.EnableRaisingEvents = true;
return;
}
@@ -600,12 +602,6 @@ public void FinishFetcher ()
FolderFetched (this.fetcher.RemoteUrl.ToString (), this.fetcher.Warnings.ToArray ());
- /* TODO
- if (!string.IsNullOrEmpty (announcements_url)) {
- this.config.SetFolderOptionalAttribute (
- target_folder_name, "announcements_url", announcements_url);
- */
-
AddRepository (target_folder_path);
FolderListChanged ();
@@ -52,9 +52,9 @@ public static class SparkleKeys {
computer_name = computer_name.Substring (0, computer_name.Length - 6);
process.StartInfo.Arguments = "-t rsa " + // crypto type
- "-P \"\"" /* password (none) */ + " " +
- "-C \"" + computer_name + "\"" /* key comment */ + " " +
- "-f \"" + key_name + "\"" /* file name */;
+ "-P \"\" " + // empty password
+ "-C \"" + computer_name + "\" " + // key comment
+ "-f \"" + key_name + "\""; // file name
process.Start ();
process.WaitForExit ();

0 comments on commit a02bd27

Please sign in to comment.