fetcher: fix support for http(s) repos. closes #1000
This commit is contained in:
parent
786deb4f05
commit
a406a0964d
|
@ -77,7 +77,7 @@ namespace SparkleLib.Git {
|
|||
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 @@ namespace SparkleLib.Git {
|
|||
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 @@ namespace SparkleLib.Git {
|
|||
public override void Stop ()
|
||||
{
|
||||
try {
|
||||
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,10 +122,12 @@ namespace SparkleLib {
|
|||
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) {
|
||||
if (!RemoteUrl.Scheme.StartsWith ("http")) {
|
||||
host_key = FetchHostKey ();
|
||||
|
||||
if (string.IsNullOrEmpty (RemoteUrl.Host) || host_key == null) {
|
||||
Failed ();
|
||||
return;
|
||||
}
|
||||
|
@ -151,6 +153,7 @@ namespace SparkleLib {
|
|||
}
|
||||
|
||||
AcceptHostKey (host_key, warn);
|
||||
}
|
||||
|
||||
this.thread = new Thread (() => {
|
||||
if (Fetch ()) {
|
||||
|
@ -159,8 +162,7 @@ namespace SparkleLib {
|
|||
|
||||
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 @@ namespace SparkleLib {
|
|||
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 @@ namespace SparkleLib {
|
|||
return random.SHA1 ();
|
||||
}
|
||||
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
if (this.thread != null)
|
||||
|
@ -254,7 +257,7 @@ namespace SparkleLib {
|
|||
}
|
||||
|
||||
|
||||
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
|
||||
|
|
|
@ -540,19 +540,20 @@ namespace SparkleShare {
|
|||
|
||||
} 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 @@ namespace SparkleShare {
|
|||
|
||||
} catch (Exception e) {
|
||||
SparkleLogger.LogInfo ("Controller", "Error moving directory: " + e.Message);
|
||||
this.watcher.EnableRaisingEvents = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -600,12 +602,6 @@ namespace SparkleShare {
|
|||
|
||||
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 @@ namespace SparkleShare {
|
|||
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 ();
|
||||
|
|
Loading…
Reference in a new issue