From 29c6fbeb3b52e5c8af39a134b519b4337fa711e1 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Tue, 3 Nov 2020 18:12:31 +0800 Subject: [PATCH] API: torrents: remove useless isMultiFile property It is only used to determine whether to use .tar extension when download is requested. However, server sent Content-Disposition header which already tells the browser the filename and it is more accurate. As such, remove this useless property. --- .../modals/torrent-details-modal/TorrentContents.tsx | 11 +++-------- .../torrent-list/TorrentListContextMenu.tsx | 5 ++++- server/services/qBittorrent/clientGatewayService.ts | 1 - .../constants/methodCallConfigs/torrentList.ts | 4 ---- shared/types/Torrent.ts | 1 - 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/client/src/javascript/components/modals/torrent-details-modal/TorrentContents.tsx b/client/src/javascript/components/modals/torrent-details-modal/TorrentContents.tsx index 111e134b..e540b3ca 100644 --- a/client/src/javascript/components/modals/torrent-details-modal/TorrentContents.tsx +++ b/client/src/javascript/components/modals/torrent-details-modal/TorrentContents.tsx @@ -55,19 +55,14 @@ class TorrentContents extends React.Component { event.preventDefault(); const {baseURI} = ConfigStore; const link = document.createElement('a'); - const {name} = TorrentStore.torrents[hash] || {}; - if (name == null) { - return; - } - - link.download = `${name}.tar`; + link.download = ''; link.href = `${baseURI}api/torrents/${hash}/contents/${this.selectedIndices.join(',')}/data`; link.style.display = 'none'; - document.body.appendChild(link); // Fix for Firefox 58+ - + document.body.appendChild(link); link.click(); + document.body.removeChild(link); }; handleFormChange = (hash: string, {event}: {event: Event | React.FormEvent}): void => { diff --git a/client/src/javascript/components/torrent-list/TorrentListContextMenu.tsx b/client/src/javascript/components/torrent-list/TorrentListContextMenu.tsx index 58c273be..cf771fee 100644 --- a/client/src/javascript/components/torrent-list/TorrentListContextMenu.tsx +++ b/client/src/javascript/components/torrent-list/TorrentListContextMenu.tsx @@ -28,11 +28,14 @@ const handleTorrentDownload = (torrent: TorrentProperties, event: React.MouseEve event.preventDefault(); const {baseURI} = ConfigStore; const link = document.createElement('a'); - link.download = torrent.isMultiFile ? `${torrent.name}.tar` : torrent.name; + + link.download = ''; link.href = `${baseURI}api/torrents/${torrent.hash}/contents/all/data`; link.style.display = 'none'; + document.body.appendChild(link); link.click(); + document.body.removeChild(link); }; const handleItemClick = (action: TorrentContextMenuAction, event: React.MouseEvent): void => { diff --git a/server/services/qBittorrent/clientGatewayService.ts b/server/services/qBittorrent/clientGatewayService.ts index 0d1cd218..4f286e3c 100644 --- a/server/services/qBittorrent/clientGatewayService.ts +++ b/server/services/qBittorrent/clientGatewayService.ts @@ -278,7 +278,6 @@ class QBittorrentClientGatewayService extends ClientGatewayService { downTotal: info.downloaded, eta: info.eta >= 8640000 ? -1 : info.eta, hash: info.hash, - isMultiFile: false, isPrivate: false, message: '', // in tracker method name: info.name, diff --git a/server/services/rTorrent/constants/methodCallConfigs/torrentList.ts b/server/services/rTorrent/constants/methodCallConfigs/torrentList.ts index 40559e66..991e5b13 100644 --- a/server/services/rTorrent/constants/methodCallConfigs/torrentList.ts +++ b/server/services/rTorrent/constants/methodCallConfigs/torrentList.ts @@ -26,10 +26,6 @@ const torrentListMethodCallConfigs = { methodCall: 'd.complete=', transformValue: booleanTransformer, }, - isMultiFile: { - methodCall: 'd.is_multi_file=', - transformValue: booleanTransformer, - }, isPrivate: { methodCall: 'd.is_private=', transformValue: booleanTransformer, diff --git a/shared/types/Torrent.ts b/shared/types/Torrent.ts index e894369a..1277314e 100644 --- a/shared/types/Torrent.ts +++ b/shared/types/Torrent.ts @@ -39,7 +39,6 @@ export interface TorrentProperties { // Torrent ETA (seconds), -1 means infinity eta: number; hash: string; - isMultiFile: boolean; isPrivate: boolean; message: string; name: string;