Transfers’ta tamamlanan torrentleri sadece listeden kaldır, eksik olanları diskten de temizle.
This commit is contained in:
@@ -397,9 +397,12 @@ app.delete("/api/torrents/:hash", requireAuth, (req, res) => {
|
|||||||
if (!entry) return res.status(404).json({ error: "torrent bulunamadı" });
|
if (!entry) return res.status(404).json({ error: "torrent bulunamadı" });
|
||||||
|
|
||||||
const { torrent, savePath } = entry;
|
const { torrent, savePath } = entry;
|
||||||
|
const isComplete = torrent?.done || (torrent?.progress ?? 0) >= 1;
|
||||||
|
const rootFolder = savePath ? path.basename(savePath) : null;
|
||||||
|
|
||||||
torrent.destroy(() => {
|
torrent.destroy(() => {
|
||||||
torrents.delete(req.params.hash);
|
torrents.delete(req.params.hash);
|
||||||
const rootFolder = savePath ? path.basename(savePath) : null;
|
if (!isComplete) {
|
||||||
if (savePath && fs.existsSync(savePath)) {
|
if (savePath && fs.existsSync(savePath)) {
|
||||||
try {
|
try {
|
||||||
fs.rmSync(savePath, { recursive: true, force: true });
|
fs.rmSync(savePath, { recursive: true, force: true });
|
||||||
@@ -412,8 +415,16 @@ app.delete("/api/torrents/:hash", requireAuth, (req, res) => {
|
|||||||
removeThumbnailsForPath(rootFolder);
|
removeThumbnailsForPath(rootFolder);
|
||||||
broadcastFileUpdate(rootFolder);
|
broadcastFileUpdate(rootFolder);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
`ℹ️ ${req.params.hash} torrent'i tamamlandığı için yalnızca Transfers listesinden kaldırıldı; dosyalar tutuldu.`
|
||||||
|
);
|
||||||
|
}
|
||||||
broadcastSnapshot();
|
broadcastSnapshot();
|
||||||
res.json({ ok: true });
|
res.json({
|
||||||
|
ok: true,
|
||||||
|
filesRemoved: !isComplete
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user