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