public GitFetcher(SparkleFetcherInfo fetcher_info, SSHAuthenticationInfo auth_info) : base(fetcher_info) { this.auth_info = auth_info; var uri_builder = new UriBuilder (RemoteUrl); if (!RemoteUrl.Scheme.Equals ("ssh") && !RemoteUrl.Scheme.Equals ("git")) uri_builder.Scheme = "ssh"; if (RemoteUrl.Host.Equals ("github.com") || RemoteUrl.Host.Equals ("gitlab.com")) { AvailableStorageTypes.Add ( new StorageTypeInfo (StorageType.LargeFiles, "Large File Storage", "Trade off versioning to save space;\nkeeps file history on the host only")); uri_builder.Scheme = "ssh"; uri_builder.UserName = "******"; if (!RemoteUrl.AbsolutePath.EndsWith (".git")) uri_builder.Path += ".git"; } else if (string.IsNullOrEmpty (RemoteUrl.UserInfo)) { uri_builder.UserName = "******"; } RemoteUrl = uri_builder.Uri; AvailableStorageTypes.Add ( new StorageTypeInfo (StorageType.Encrypted, "Encrypted Storage", "Trade off efficiency for privacy;\nencrypts before storing files on the host")); }
public void StartFetcher(SparkleFetcherInfo info) { string tmp_path = Config.TmpPath; if (!Directory.Exists(tmp_path)) { Directory.CreateDirectory(tmp_path); File.SetAttributes(tmp_path, File.GetAttributes(tmp_path) | FileAttributes.Hidden); } string canonical_name = Path.GetFileName(info.RemotePath); string backend = info.Backend; if (string.IsNullOrEmpty(backend)) { backend = SparkleFetcherBase.GetBackend(info.Address); } info.TargetDirectory = Path.Combine(tmp_path, canonical_name); try { this.fetcher = (SparkleFetcherBase)Activator.CreateInstance( Type.GetType("SparkleLib." + backend + ".SparkleFetcher, SparkleLib." + backend), info); } catch (Exception e) { SparkleLogger.LogInfo("Controller", "Failed to load '" + backend + "' backend for '" + canonical_name + "' " + e.Message); FolderFetchError(Path.Combine(info.Address, info.RemotePath).Replace(@"\", "/"), new string [] { "Failed to load \"" + backend + "\" backend for \"" + canonical_name + "\"" }); return; } this.fetcher.Finished += delegate(bool repo_is_encrypted, bool repo_is_empty, string [] warnings) { if (repo_is_encrypted && repo_is_empty) { ShowSetupWindowEvent(PageType.CryptoSetup); } else if (repo_is_encrypted) { ShowSetupWindowEvent(PageType.CryptoPassword); } else { FinishFetcher(); } }; this.fetcher.Failed += delegate { FolderFetchError(this.fetcher.RemoteUrl.ToString(), this.fetcher.Errors); StopFetcher(); }; this.fetcher.ProgressChanged += delegate(double percentage, double speed) { FolderFetching(percentage, speed); }; this.fetcher.Start(); }
public SparkleFetcher(SparkleFetcherInfo info) : base(info) { if (RemoteUrl.ToString().StartsWith("ssh+")) { RemoteUrl = new Uri("ssh" + RemoteUrl.ToString().Substring(RemoteUrl.ToString().IndexOf("://"))); } Uri uri = RemoteUrl; if (!uri.Scheme.Equals("ssh") && !uri.Scheme.Equals("https") && !uri.Scheme.Equals("http") && !uri.Scheme.Equals("git")) { uri = new Uri("ssh://" + uri); } if (uri.Host.Equals("gitorious.org") && !uri.Scheme.StartsWith("http")) { if (!uri.AbsolutePath.Equals("/") && !uri.AbsolutePath.EndsWith(".git")) { uri = new Uri("ssh://[email protected]" + uri.AbsolutePath + ".git"); } else { uri = new Uri("ssh://[email protected]" + uri.AbsolutePath); } } else if (uri.Host.Equals("github.com") && !uri.Scheme.StartsWith("http")) { uri = new Uri("ssh://[email protected]" + uri.AbsolutePath); } else if (uri.Host.Equals("bitbucket.org") && !uri.Scheme.StartsWith("http")) { // Nothing really } else { if (string.IsNullOrEmpty(uri.UserInfo) && !uri.Scheme.StartsWith("http")) { if (uri.Port == -1) { uri = new Uri(uri.Scheme + "://storage@" + uri.Host + uri.AbsolutePath); } else { uri = new Uri(uri.Scheme + "://storage@" + uri.Host + ":" + uri.Port + uri.AbsolutePath); } } this.use_git_bin = false; // TODO } RemoteUrl = uri; }
public void AddPageCompleted(string address, string remote_path) { SyncingFolder = Path.GetFileName(remote_path); if (remote_path.EndsWith(".git")) { SyncingFolder = remote_path.Substring(0, remote_path.Length - 4); } SyncingFolder = SyncingFolder.Replace("-crypto", ""); SyncingFolder = SyncingFolder.Replace("_", " "); ProgressBarPercentage = 1.0; ChangePageEvent(PageType.Syncing, null); address = Uri.EscapeUriString(address.Trim()); remote_path = remote_path.Trim(); remote_path = remote_path.TrimEnd("/".ToCharArray()); if (SelectedPlugin.PathUsesLowerCase) { remote_path = remote_path.ToLower(); } PreviousAddress = address; PreviousPath = remote_path; Program.Controller.FolderFetched += AddPageFetchedDelegate; Program.Controller.FolderFetchError += AddPageFetchErrorDelegate; Program.Controller.FolderFetching += SyncingPageFetchingDelegate; SparkleFetcherInfo info = new SparkleFetcherInfo { Address = address, Fingerprint = SelectedPlugin.Fingerprint, RemotePath = remote_path, FetchPriorHistory = this.fetch_prior_history, AnnouncementsUrl = SelectedPlugin.AnnouncementsUrl, Backend = SelectedPlugin.Backend }; new Thread(() => { Program.Controller.StartFetcher(info); }).Start(); }
public void InvitePageCompleted() { SyncingFolder = Path.GetFileName(PendingInvite.RemotePath); if (PendingInvite.RemotePath.EndsWith(".git")) { SyncingFolder = PendingInvite.RemotePath.Substring(0, PendingInvite.RemotePath.Length - 4); } SyncingFolder = SyncingFolder.Replace("-crypto", ""); SyncingFolder = SyncingFolder.Replace("_", " "); PreviousAddress = PendingInvite.Address; PreviousPath = PendingInvite.RemotePath; ChangePageEvent(PageType.Syncing, null); new Thread(() => { if (!PendingInvite.Accept(Program.Controller.CurrentUser.PublicKey)) { PreviousUrl = PendingInvite.Address + PendingInvite.RemotePath.TrimStart("/".ToCharArray()); ChangePageEvent(PageType.Error, new string [] { "error: Failed to upload the public key" }); return; } Program.Controller.FolderFetched += InvitePageFetchedDelegate; Program.Controller.FolderFetchError += InvitePageFetchErrorDelegate; Program.Controller.FolderFetching += SyncingPageFetchingDelegate; SparkleFetcherInfo info = new SparkleFetcherInfo { Address = PendingInvite.Address, Fingerprint = PendingInvite.Fingerprint, RemotePath = PendingInvite.RemotePath, FetchPriorHistory = false, // TODO: checkbox on invite page AnnouncementsUrl = PendingInvite.AnnouncementsUrl }; Program.Controller.StartFetcher(info); }).Start(); }
public void StartFetcher(SparkleFetcherInfo info) { string canonical_name = Path.GetFileName(info.RemotePath); string backend = info.Backend; if (string.IsNullOrEmpty(backend)) { backend = BaseFetcher.GetBackend(info.Address); } info.TargetDirectory = Path.Combine(Config.TmpPath, canonical_name); if (Directory.Exists(info.TargetDirectory)) { Directory.Delete(info.TargetDirectory, recursive: true); } try { this.fetcher = (BaseFetcher)Activator.CreateInstance( Type.GetType("Sparkles." + backend + "." + backend + "Fetcher, Sparkles." + backend), new object [] { info, UserAuthenticationInfo }); } catch (Exception e) { Logger.LogInfo("Controller", "Failed to load '" + backend + "' backend for '" + canonical_name + "' " + e.Message); FolderFetchError(Path.Combine(info.Address, info.RemotePath).Replace(@"\", "/"), new string [] { "Failed to load \"" + backend + "\" backend for \"" + canonical_name + "\"" }); return; } this.fetcher.Finished += FetcherFinishedDelegate; this.fetcher.Failed += FetcherFailedDelegate; this.fetcher.ProgressChanged += FetcherProgressChangedDelgate; this.fetcher.Start(); }
public GitFetcher(SparkleFetcherInfo fetcher_info, SSHAuthenticationInfo auth_info) : base(fetcher_info) { this.auth_info = auth_info; var uri_builder = new UriBuilder(RemoteUrl); if (!RemoteUrl.Scheme.Equals("ssh") && !RemoteUrl.Scheme.Equals("git")) { uri_builder.Scheme = "ssh"; } if (RemoteUrl.Host.Equals("github.com") || RemoteUrl.Host.Equals("gitlab.com")) { AvailableStorageTypes.Add( new StorageTypeInfo(StorageType.LargeFiles, "Large File Storage", "Trade off versioning to save space;\nkeeps file history on the host only")); uri_builder.Scheme = "ssh"; uri_builder.UserName = "******"; if (!RemoteUrl.AbsolutePath.EndsWith(".git")) { uri_builder.Path += ".git"; } } else if (string.IsNullOrEmpty(RemoteUrl.UserInfo)) { uri_builder.UserName = "******"; } RemoteUrl = uri_builder.Uri; AvailableStorageTypes.Add( new StorageTypeInfo(StorageType.Encrypted, "Encrypted Storage", "Trade off efficiency for privacy;\nencrypts before storing files on the host")); }