fix in download torrents
This commit is contained in:
@@ -257,9 +257,7 @@ def torrent_file_export_link(torrent_hash: str):
|
||||
if not profile:
|
||||
return jsonify({"ok": False, "error": "No profile"}), 400
|
||||
try:
|
||||
# Note: Export availability is checked before the UI receives a temporary /download URL.
|
||||
item = rtorrent.export_torrent_file(profile, torrent_hash)
|
||||
_cleanup_staged_file(profile, item["path"], bool(item.get("local")))
|
||||
# Note: Create only a short-lived link here; the actual .torrent export runs once when the browser opens /download/<token>.
|
||||
link = pdf_preview_links.create_torrent_file_download_link(torrent_hash, int(profile.get("id") or 0), int(default_user_id() or 0))
|
||||
return ok({"url": url_for("main.temporary_download", token=link["token"]), "expires_in": link["expires_in"]})
|
||||
except Exception as exc:
|
||||
@@ -276,15 +274,7 @@ def torrent_files_export_zip_link():
|
||||
if not hashes:
|
||||
return jsonify({"ok": False, "error": "No torrents selected"}), 400
|
||||
try:
|
||||
# Note: Each hash is checked before the temporary ZIP export link is returned to the UI.
|
||||
staged_paths = []
|
||||
try:
|
||||
for h in hashes:
|
||||
item = rtorrent.export_torrent_file(profile, h)
|
||||
staged_paths.append((item["path"], bool(item.get("local"))))
|
||||
finally:
|
||||
for path, is_local in staged_paths:
|
||||
_cleanup_staged_file(profile, path, is_local)
|
||||
# Note: Store only the selected hashes in the temporary token; exporting each .torrent now happens once during the real ZIP download.
|
||||
link = pdf_preview_links.create_torrent_files_zip_download_link(hashes, int(profile.get("id") or 0), int(default_user_id() or 0))
|
||||
return ok({"url": url_for("main.temporary_download", token=link["token"]), "expires_in": link["expires_in"]})
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user