Exemple #1
0
        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);
         }
     }
 }
Exemple #3
0
        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);
                }
            }
        }
Exemple #4
0
 public FastResume SaveFastResume()
 {
     return(manager.SaveFastResume());
 }