Skip to content

Commit

Permalink
Merge pull request #3803 from devos50/fix_torrent_export
Browse files Browse the repository at this point in the history
Fixed exporting of torrents
  • Loading branch information
xoriole authored Aug 20, 2018
2 parents 6095c7e + 56520ed commit 4cec53c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
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

0 comments on commit 4cec53c

Please sign in to comment.