From db8cf86c396e40efc40d60262215f2f87a8019df Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Mon, 20 Aug 2018 11:26:31 +0200 Subject: [PATCH 1/2] Fixed torrent export functionality It will now properly return an error 404 if the torrent cannot be found in the torrent store --- Tribler/Core/Modules/restapi/downloads_endpoint.py | 6 +++--- .../Test/Core/Modules/RestApi/test_downloads_endpoint.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Tribler/Core/Modules/restapi/downloads_endpoint.py b/Tribler/Core/Modules/restapi/downloads_endpoint.py index 5a5c61dd467..e441349db65 100644 --- a/Tribler/Core/Modules/restapi/downloads_endpoint.py +++ b/Tribler/Core/Modules/restapi/downloads_endpoint.py @@ -500,13 +500,13 @@ def render_GET(self, request): The contents of the .torrent file. """ - download = self.session.get_download(self.infohash) - if not download: + torrent = self.session.get_collected_torrent(self.infohash) + if not torrent: return DownloadExportTorrentEndpoint.return_404(request) request.setHeader(b'content-type', 'application/x-bittorrent') request.setHeader(b'Content-Disposition', 'attachment; filename=%s.torrent' % self.infohash.encode('hex')) - return self.session.get_collected_torrent(self.infohash) + return torrent class DownloadFilesEndpoint(DownloadBaseEndpoint): diff --git a/Tribler/Test/Core/Modules/RestApi/test_downloads_endpoint.py b/Tribler/Test/Core/Modules/RestApi/test_downloads_endpoint.py index f199959656b..bbdd2c3fae2 100644 --- a/Tribler/Test/Core/Modules/RestApi/test_downloads_endpoint.py +++ b/Tribler/Test/Core/Modules/RestApi/test_downloads_endpoint.py @@ -20,6 +20,7 @@ def setUpPreSession(self): super(TestDownloadsEndpoint, self).setUpPreSession() self.config.set_libtorrent_enabled(True) self.config.set_megacache_enabled(True) + self.config.set_torrent_store_enabled(True) @deferred(timeout=10) def test_get_downloads_no_downloads(self): From 56520ed49955baf8c054257ed1f59f3d13563ba9 Mon Sep 17 00:00:00 2001 From: Martijn de Vos Date: Mon, 20 Aug 2018 11:33:50 +0200 Subject: [PATCH 2/2] Disabled export functionality in GUI in some cases --- TriblerGUI/widgets/downloadspage.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/TriblerGUI/widgets/downloadspage.py b/TriblerGUI/widgets/downloadspage.py index 6c29a5d8d54..6a2bf2c695e 100644 --- a/TriblerGUI/widgets/downloadspage.py +++ b/TriblerGUI/widgets/downloadspage.py @@ -10,7 +10,7 @@ from TriblerGUI.defs import DOWNLOADS_FILTER_ALL, DOWNLOADS_FILTER_DOWNLOADING, DOWNLOADS_FILTER_COMPLETED, \ DOWNLOADS_FILTER_ACTIVE, DOWNLOADS_FILTER_INACTIVE, DOWNLOADS_FILTER_CREDITMINING, DOWNLOADS_FILTER_DEFINITION, \ DLSTATUS_STOPPED, DLSTATUS_STOPPED_ON_ERROR, BUTTON_TYPE_NORMAL, BUTTON_TYPE_CONFIRM, DLSTATUS_METADATA, \ - DLSTATUS_HASHCHECKING, DLSTATUS_WAITING4HASHCHECK + DLSTATUS_HASHCHECKING, DLSTATUS_WAITING4HASHCHECK, DLSTATUS_CIRCUITS from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog from TriblerGUI.widgets.downloadwidgetitem import DownloadWidgetItem from TriblerGUI.tribler_request_manager import TriblerRequestManager @@ -481,8 +481,11 @@ def on_right_click_item(self, pos): menu.addSeparator() menu.addAction(force_recheck_action) menu.addSeparator() - menu.addAction(export_download_action) - menu.addSeparator() + + exclude_states = [DLSTATUS_METADATA, DLSTATUS_CIRCUITS, DLSTATUS_HASHCHECKING, DLSTATUS_WAITING4HASHCHECK] + if len(self.selected_items) == 1 and self.selected_items[0].get_raw_download_status() not in exclude_states: + menu.addAction(export_download_action) + menu.addSeparator() menu_anon_level = menu.addMenu("Change anonymity") menu_anon_level.addAction(no_anon_action) menu_anon_level.addAction(one_hop_anon_action)