Transfers’ta tamamlanan torrentleri sadece listeden kaldır, eksik olanları diskten de temizle.

This commit is contained in:
2025-10-26 20:05:25 +03:00
parent b9e59288fc
commit be4ffd6575

View File

@@ -397,9 +397,12 @@ app.delete("/api/torrents/:hash", requireAuth, (req, res) => {
if (!entry) return res.status(404).json({ error: "torrent bulunamadı" });
const { torrent, savePath } = entry;
const isComplete = torrent?.done || (torrent?.progress ?? 0) >= 1;
const rootFolder = savePath ? path.basename(savePath) : null;
torrent.destroy(() => {
torrents.delete(req.params.hash);
const rootFolder = savePath ? path.basename(savePath) : null;
if (!isComplete) {
if (savePath && fs.existsSync(savePath)) {
try {
fs.rmSync(savePath, { recursive: true, force: true });
@@ -412,8 +415,16 @@ app.delete("/api/torrents/:hash", requireAuth, (req, res) => {
removeThumbnailsForPath(rootFolder);
broadcastFileUpdate(rootFolder);
}
} else {
console.log(
` ${req.params.hash} torrent'i tamamlandığı için yalnızca Transfers listesinden kaldırıldı; dosyalar tutuldu.`
);
}
broadcastSnapshot();
res.json({ ok: true });
res.json({
ok: true,
filesRemoved: !isComplete
});
});
});