mirror of
https://github.com/PR0M3TH3AN/bitvid-seeder.git
synced 2026-11-06 12:51:11 +00:00
update
This commit is contained in:
1 parent
48cad129ec
commit
a75c91ee3f
2 files changed
+31
-3
No files matched your search
@@ -262,6 +262,25 @@ app.get("/torrents", (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Add after existing routes in server.js
|
||||
app.get("/download/:infoHash", async (req, res) => {
|
||||
const infoHash = req.params.infoHash;
|
||||
const savedData = savedTorrents.find((t) => t.infoHash === infoHash);
|
||||
if (!savedData) {
|
||||
return res.status(404).json({ error: "Torrent not found" });
|
||||
}
|
||||
const filePath = path.join(STORAGE_DIR, savedData.name);
|
||||
if (!(await pathExists(filePath))) {
|
||||
return res.status(404).json({ error: "File not found" });
|
||||
}
|
||||
res.download(filePath, savedData.name, (err) => {
|
||||
if (err) {
|
||||
logger.error("Error downloading file: " + err);
|
||||
res.status(500).json({ error: "Error downloading file" });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Pause a torrent
|
||||
app.post("/pause/:infoHash", async (req, res) => {
|
||||
const infoHash = req.params.infoHash;
|
||||
|
||||
Reference in new issue
Block a user