public void Stop() { if (torrentManager.State != TorrentState.Hashing) { torrentManager.Stop(); while (torrentManager.State != TorrentState.Stopped) { Thread.Sleep(250); } BEncodedList bl = new BEncodedList(); FastResume fr = torrentManager.SaveFastResume(); BEncodedDictionary item = fr.Encode(); bl.Add(item); File.WriteAllBytes(fastResumeFile, bl.Encode()); } else { torrentManager.Stop(); } File.WriteAllBytes(dhtNodesFile, clientEngine.DhtEngine.SaveNodes()); clientEngine.Dispose(); }
public void SaveRecovery() { if (TM.HasMetadata) { var RecoveryFile = Environment.ExpandEnvironmentVariables(TORRENT_DIR + $"\\{TM.InfoHash.ToHex()}.rec"); var FR = TM.SaveFastResume(); if (File.Exists(RecoveryFile)) { File.Delete(RecoveryFile); } using (var FS = File.Create(RecoveryFile)) { FR.Encode(FS); } } }
public TorrentManagerSave(TorrentManager manager) { state = manager.State; if (manager.State != TorrentState.Hashing && manager.HasMetadata) { resume = manager.SaveFastResume().Encode().Encode(); } downloading = new SerializableDictionary <string, bool>(); if (manager.Torrent != null) { foreach (var file in manager.Torrent.Files) { downloading.Add(file.Path, file.Priority != Priority.DoNotDownload); } } }
public FastResume SaveFastResume() { return(manager.SaveFastResume()); }