Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed exporting of torrents #3803

Merged
merged 2 commits into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Tribler/Core/Modules/restapi/downloads_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 6 additions & 3 deletions TriblerGUI/widgets/downloadspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down