@@ -827,12 +827,42 @@ func (tm *TorrentManager) listenTorrentProgress() {
827
827
828
828
if t .Finished () {
829
829
tm .lock .Lock ()
830
- err := os .Symlink (
831
- path .Join (defaultTmpFilePath , t .InfoHash ()),
832
- path .Join (tm .DataDir , t .InfoHash ()),
833
- )
830
+ if _ , err := os .Stat (path .Join (tm .DataDir , t .InfoHash ())); err == nil {
831
+ log .Debug ("Path exist" , "hash" , t .Torrent .InfoHash (), "path" , path .Join (tm .DataDir , t .InfoHash ()))
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 )
838
+ } else {
839
+ //log.Info("Path not exist", "hash", t.Torrent.InfoHash(), "path", path.Join(tm.DataDir, t.InfoHash()))
840
+ err := os .Symlink (
841
+ path .Join (defaultTmpFilePath , t .InfoHash ()),
842
+ path .Join (tm .DataDir , t .InfoHash ()),
843
+ )
834
844
835
- if err != nil {
845
+ if err != nil {
846
+ //log.Warn("Seeding path error", "hash", t.Torrent.InfoHash(), "size", t.bytesCompleted, "miss", t.bytesMissing, "loop", log_counter)
847
+ err = os .Remove (
848
+ path .Join (tm .DataDir , t .InfoHash ()),
849
+ )
850
+ if err != nil {
851
+ // log.Warn("Fix path error", "hash", t.Torrent.InfoHash(), "size", t.bytesCompleted, "miss", t.bytesMissing, "loop", log_counter)
852
+ } else {
853
+ log .Debug ("Fix path success" , "hash" , t .Torrent .InfoHash (), "size" , t .bytesCompleted , "miss" , t .bytesMissing , "loop" , log_counter )
854
+ }
855
+ } else {
856
+ delete (tm .activeTorrents , ih )
857
+ tm .seedingTorrents [ih ] = t
858
+ t .Seed ()
859
+ t .loop = defaultSeedInterval / queryTimeInterval
860
+ total_size += uint64 (t .bytesCompleted )
861
+ current_size += uint64 (t .bytesCompleted )
862
+ }
863
+ }
864
+
865
+ /*if err != nil {
836
866
//log.Warn("Seeding path error", "hash", t.Torrent.InfoHash(), "size", t.bytesCompleted, "miss", t.bytesMissing, "loop", log_counter)
837
867
err = os.Remove(
838
868
path.Join(tm.DataDir, t.InfoHash()),
@@ -849,7 +879,7 @@ func (tm *TorrentManager) listenTorrentProgress() {
849
879
t.loop = defaultSeedInterval / queryTimeInterval
850
880
total_size += uint64(t.bytesCompleted)
851
881
current_size += uint64(t.bytesCompleted)
852
- }
882
+ }*/
853
883
tm .lock .Unlock ()
854
884
continue
855
885
}
0 commit comments