修改Tracker服务器相关bug
Change-Id: Id3ec61034575bd794724be98f832f8c065448b92
diff --git a/src/main/java/com/pt/service/TorrentService.java b/src/main/java/com/pt/service/TorrentService.java
index 3c9d28d..e61e874 100644
--- a/src/main/java/com/pt/service/TorrentService.java
+++ b/src/main/java/com/pt/service/TorrentService.java
@@ -8,6 +8,7 @@
import java.security.MessageDigest;
import java.time.LocalDateTime;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -43,6 +44,9 @@
}
length = totalLength;
}
+ // 添加Tracker地址到种子文件中
+ torrentDict.put("announce", "http://your-tracker-url/api/tracker/announce");
+
// 保存到数据库
Optional<TorrentMeta> existing = torrentMetaRepository.findByInfoHash(infoHash);
@@ -55,7 +59,7 @@
meta.setInfoHash(infoHash);
meta.setSize(length);
meta.setUploadTime(LocalDateTime.now());
- meta.setTorrentData(torrentBytes);
+ meta.setTorrentData(BencodeCodec.encode(torrentDict)); // 使用更新后的字典编码
return torrentMetaRepository.save(meta);
}
@@ -70,4 +74,4 @@
}
return sb.toString();
}
-}
+}
\ No newline at end of file