55 "crypto/sha1"
66 //"errors"
77 "fmt"
8- "github.com/anacrolix/missinggo/slices"
8+ // "github.com/anacrolix/missinggo/slices"
99 "github.com/bradfitz/iter"
1010 "github.com/edsrzf/mmap-go"
1111 "io"
@@ -114,9 +114,9 @@ func (t *Torrent) ReloadFile(files []string, datas [][]byte, tm *TorrentManager)
114114 if err != nil {
115115 return
116116 }
117- t .Torrent = torrent
118117 <- torrent .GotInfo ()
119118 torrent .VerifyData ()
119+ t .Torrent = torrent
120120 t .Pause ()
121121}
122122
@@ -148,9 +148,9 @@ func (t *Torrent) ReloadTorrent(data []byte, tm *TorrentManager) {
148148 if err != nil {
149149 return
150150 }
151- t .Torrent = torrent
152151 <- torrent .GotInfo ()
153152 torrent .VerifyData ()
153+ t .Torrent = torrent
154154 t .Pause ()
155155}
156156
@@ -354,8 +354,8 @@ func (tm *TorrentManager) Close() error {
354354}
355355
356356func (tm * TorrentManager ) dropAll () {
357- tm .lock .Lock ()
358- tm .lock .Unlock ()
357+ // tm.lock.Lock()
358+ // tm.lock.Unlock()
359359 defer tm .client .Close ()
360360 for _ , t := range tm .torrents {
361361 stats := t .Stats ()
@@ -495,13 +495,13 @@ func (tm *TorrentManager) AddTorrent(filePath string, BytesRequested int64) *Tor
495495 if err != nil {
496496 return nil
497497 }
498- var ss []string
499- slices .MakeInto (& ss , mi .Nodes )
500- tm .client .AddDHTNodes (ss )
501- torrent := tm .CreateTorrent (t , BytesRequested , torrentPending , ih )
498+ //var ss []string
499+ //slices.MakeInto(&ss, mi.Nodes)
500+ //tm.client.AddDHTNodes(ss)
502501 <- t .GotInfo ()
503502 t .VerifyData ()
504- torrent .SeedInQueue ()
503+ torrent := tm .CreateTorrent (t , BytesRequested , torrentPending , ih )
504+ torrent .Pause () //SeedInQueue()
505505 return torrent
506506 } else {
507507 spec .Storage = storage .NewFile (TmpDir )
@@ -512,12 +512,12 @@ func (tm *TorrentManager) AddTorrent(filePath string, BytesRequested int64) *Tor
512512 if err != nil {
513513 return nil
514514 }
515- var ss []string
516- slices .MakeInto (& ss , mi .Nodes )
517- tm .client .AddDHTNodes (ss )
518- torrent := tm .CreateTorrent (t , BytesRequested , torrentPending , ih )
515+ //var ss []string
516+ //slices.MakeInto(&ss, mi.Nodes)
517+ //tm.client.AddDHTNodes(ss)
519518 <- t .GotInfo ()
520519 t .VerifyData ()
520+ torrent := tm .CreateTorrent (t , BytesRequested , torrentPending , ih )
521521 torrent .Pause ()
522522 return torrent
523523 }
@@ -825,16 +825,18 @@ func (tm *TorrentManager) listenTorrentProgress() {
825825 t .bytesMissing = t .BytesMissing ()
826826
827827 if t .Finished () {
828- os .Symlink (
828+ err := os .Symlink (
829829 path .Join (defaultTmpFilePath , t .InfoHash ()),
830830 path .Join (tm .DataDir , t .InfoHash ()),
831831 )
832- delete (tm .activeTorrents , ih )
833- tm .seedingTorrents [ih ] = t
834- t .Seed ()
835- t .loop = defaultSeedInterval / queryTimeInterval
836- total_size += uint64 (t .bytesCompleted )
837- current_size += uint64 (t .bytesCompleted )
832+ if err == nil {
833+ delete (tm .activeTorrents , ih )
834+ tm .seedingTorrents [ih ] = t
835+ t .Seed ()
836+ t .loop = defaultSeedInterval / queryTimeInterval
837+ total_size += uint64 (t .bytesCompleted )
838+ current_size += uint64 (t .bytesCompleted )
839+ }
838840 continue
839841 }
840842
@@ -926,6 +928,7 @@ func (tm *TorrentManager) listenTorrentProgress() {
926928 }
927929 timer .Reset (time .Second * queryTimeInterval )
928930 case <- tm .closeAll :
931+ log .Info ("Listen torrent progress closed" )
929932 return
930933 }
931934 }
0 commit comments