public void StopFetcher () { this.fetcher.Stop (); this.fetcher.Dispose (); this.fetcher = null; this.watcher.EnableRaisingEvents = true; }
public void FinishFetcher (StorageType selected_storage_type) { this.watcher.EnableRaisingEvents = false; string identifier = this.fetcher.Complete (selected_storage_type); string target_folder_path = DetermineFolderPath (); string target_folder_name = Path.GetFileName (target_folder_path); try { Directory.Move (this.fetcher.TargetFolder, target_folder_path); } catch (Exception e) { Logger.LogInfo ("Controller", "Error moving directory, trying again...", e); try { ClearDirectoryAttributes (this.fetcher.TargetFolder); Directory.Move (this.fetcher.TargetFolder, target_folder_path); } catch (Exception x) { Logger.LogInfo ("Controller", "Error moving directory", x); this.fetcher.Dispose (); this.fetcher = null; this.watcher.EnableRaisingEvents = true; return; } } string backend = BaseFetcher.GetBackend (this.fetcher.RemoteUrl.ToString ()); Config.AddFolder (target_folder_name, identifier, this.fetcher.RemoteUrl.ToString (), backend); if (this.fetcher.FetchedRepoStorageType != StorageType.Plain) { Config.SetFolderOptionalAttribute (target_folder_name, "storage_type", this.fetcher.FetchedRepoStorageType.ToString ()); } if (this.fetcher.OriginalFetcherInfo.AnnouncementsUrl != null) { Config.SetFolderOptionalAttribute (target_folder_name, "announcements_url", this.fetcher.OriginalFetcherInfo.AnnouncementsUrl); } AddRepository (target_folder_path); RepositoriesLoaded = true; FolderListChanged (); FolderFetched (this.fetcher.RemoteUrl.ToString (), this.fetcher.Warnings.ToArray ()); this.fetcher.Dispose (); this.fetcher = null; this.watcher.EnableRaisingEvents = true; }
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, 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 (); }