Seedr: Prevent deletion in-progress torrent to fix stuck download

Add a check to raise an exception if a torrent is still downloading when attempting to delete folder contents. Included a placeholder video file for exception handling use. This ensures ongoing downloads are not interrupted inadvertently.
This commit is contained in:
mhdzumair
2024-12-22 17:50:21 +05:30
parent 6733432663
commit ef142b7f9e
2 changed files with 5 additions and 2 deletions
Binary file not shown.
+5 -2
View File
@@ -100,8 +100,11 @@ async def ensure_space_available(seedr: Seedr, required_space: int | float) -> N
# Delete folder contents first
sub_content = await seedr.list_contents(folder["id"])
for torrent in sub_content["torrents"]:
await seedr.delete_item(torrent["id"], "torrent")
if sub_content["torrents"]:
# Raise exception if torrent is still downloading.
raise ProviderException(
"An existing torrent is being downloaded", "torrent_downloading.mp4"
)
for subfolder in sub_content["folders"]:
await seedr.delete_item(subfolder["id"], "folder")