Merge branch 'release-2.1.1'

This commit is contained in:
Calum Lind 2022-07-10 13:20:41 +01:00
commit 0b5f45b486
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3
8 changed files with 44 additions and 26 deletions

View File

@ -65,7 +65,7 @@ jobs:
path: /cores path: /cores
test-windows: test-windows:
runs-on: windows-latest runs-on: windows-2019
strategy: strategy:
matrix: matrix:
python-version: ["3.7", "3.10"] python-version: ["3.7", "3.10"]

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## 2.1.1 (2022-07-10)
### Core
- Fix missing trackers added via magnet
- Fix handling magnets with tracker tiers
## 2.1.0 (2022-06-28) ## 2.1.0 (2022-06-28)
### Breaking changes ### Breaking changes

View File

@ -734,6 +734,8 @@ MAGNET_SCHEME = 'magnet:?'
XT_BTIH_PARAM = 'xt=urn:btih:' XT_BTIH_PARAM = 'xt=urn:btih:'
DN_PARAM = 'dn=' DN_PARAM = 'dn='
TR_PARAM = 'tr=' TR_PARAM = 'tr='
TR_TIER_PARAM = 'tr.'
TR_TIER_REGEX = re.compile(r'^tr.(\d+)=(\S+)')
def is_magnet(uri): def is_magnet(uri):
@ -776,8 +778,6 @@ def get_magnet_info(uri):
""" """
tr0_param = 'tr.'
tr0_param_regex = re.compile(r'^tr.(\d+)=(\S+)')
if not uri.startswith(MAGNET_SCHEME): if not uri.startswith(MAGNET_SCHEME):
return {} return {}
@ -805,12 +805,14 @@ def get_magnet_info(uri):
tracker = unquote_plus(param[len(TR_PARAM) :]) tracker = unquote_plus(param[len(TR_PARAM) :])
trackers[tracker] = tier trackers[tracker] = tier
tier += 1 tier += 1
elif param.startswith(tr0_param): elif param.startswith(TR_TIER_PARAM):
try: tracker_match = re.match(TR_TIER_REGEX, param)
tier, tracker = re.match(tr0_param_regex, param).groups() if not tracker_match:
trackers[tracker] = tier continue
except AttributeError:
pass tier, tracker = tracker_match.groups()
tracker = unquote_plus(tracker)
trackers[tracker] = int(tier)
if info_hash: if info_hash:
if not name: if not name:

View File

@ -436,8 +436,8 @@ class TorrentManager(component.Component):
magnet_info = get_magnet_info(magnet) magnet_info = get_magnet_info(magnet)
if magnet_info: if magnet_info:
add_torrent_params['name'] = magnet_info['name'] add_torrent_params['name'] = magnet_info['name']
add_torrent_params['trackers'] = list(magnet_info['trackers'])
torrent_id = magnet_info['info_hash'] torrent_id = magnet_info['info_hash']
# Workaround lt 1.2 bug for magnet resume data with no metadata
add_torrent_params['info_hash'] = bytes(bytearray.fromhex(torrent_id)) add_torrent_params['info_hash'] = bytes(bytearray.fromhex(torrent_id))
else: else:
raise AddTorrentError( raise AddTorrentError(

View File

@ -7,6 +7,7 @@
import os import os
import sys import sys
import tarfile import tarfile
from urllib.parse import quote_plus
import pytest import pytest
@ -19,6 +20,7 @@ from deluge.common import (
fsize, fsize,
fspeed, fspeed,
ftime, ftime,
get_magnet_info,
get_path_size, get_path_size,
is_infohash, is_infohash,
is_interface, is_interface,
@ -209,3 +211,16 @@ class TestCommon:
if tar_info.name == 'archive_message.txt': if tar_info.name == 'archive_message.txt':
result = tar.extractfile(tar_info).read().decode() result = tar.extractfile(tar_info).read().decode()
assert result == 'test' assert result == 'test'
def test_get_magnet_info_tiers(self):
tracker1 = 'udp://tracker1.example.com'
tracker2 = 'udp://tracker2.example.com'
magnet = (
'magnet:?xt=urn:btih:SU5225URMTUEQLDXQWRB2EQWN6KLTYKN'
f'&tr.1={quote_plus(tracker1)}'
f'&tr.2={quote_plus(tracker2)}'
)
result = get_magnet_info(magnet)
assert result['info_hash'] == '953bad769164e8482c7785a21d12166f94b9e14d'
assert result['trackers'][tracker1] == 1
assert result['trackers'][tracker2] == 2

View File

@ -222,10 +222,15 @@ class TestCore(BaseTestCase):
@pytest_twisted.inlineCallbacks @pytest_twisted.inlineCallbacks
def test_add_torrent_magnet(self): def test_add_torrent_magnet(self):
info_hash = '60d5d82328b4547511fdeac9bf4d0112daa0ce00' info_hash = '60d5d82328b4547511fdeac9bf4d0112daa0ce00'
uri = deluge.common.create_magnet_uri(info_hash) tracker = 'udp://tracker.example.com'
name = 'test magnet'
uri = deluge.common.create_magnet_uri(info_hash, name=name, trackers=[tracker])
options = {} options = {}
torrent_id = yield self.core.add_torrent_magnet(uri, options) torrent_id = yield self.core.add_torrent_magnet(uri, options)
assert torrent_id == info_hash assert torrent_id == info_hash
torrent_status = self.core.get_torrent_status(torrent_id, ['name', 'trackers'])
assert torrent_status['trackers'][0]['url'] == tracker
assert torrent_status['name'] == name
def test_resume_torrent(self): def test_resume_torrent(self):
tid1 = self.add_torrent('test.torrent', paused=True) tid1 = self.add_torrent('test.torrent', paused=True)

View File

@ -48,9 +48,9 @@ One-click [**Install**](https://dl.flathub.org/repo/appstream/org.deluge_torrent
## <i class="fa fa-windows"></i> Windows ## <i class="fa fa-windows"></i> Windows
Unfortunately no official installer package currently available. Download [installer](https://ftp.osuosl.org/pub/deluge/windows/?C=M;O=D)
See [Alternative Installs](#alternative-installs) Availble for Windows 7, 8 & 10 for both 32-bit and 64-bit OSes.
## <i class="fa fa-apple"></i> macOS ## <i class="fa fa-apple"></i> macOS
@ -96,15 +96,6 @@ The [development PPA] contains daily builds from the `develop` branch.
sudo add-apt-repository -u ppa:deluge-team/develop sudo add-apt-repository -u ppa:deluge-team/develop
sudo apt install deluge sudo apt install deluge
### Windows Community
Due to move to GTK3 and Python 3 and problems with pyinstaller there are only community
created installers available.
Check sticky topics in [Windows Forum] for latest updates.
For reference [issue #3201] is tracking progress on an official installer.
### macOS Community ### macOS Community
#### Unofficial `.app` packages #### Unofficial `.app` packages
@ -138,7 +129,5 @@ sudo port install deluge
[development ppa]: https://launchpad.net/~deluge-team/+archive/ubuntu/develop/ [development ppa]: https://launchpad.net/~deluge-team/+archive/ubuntu/develop/
[stable ppa]: https://launchpad.net/~deluge-team/+archive/ubuntu/stable/ [stable ppa]: https://launchpad.net/~deluge-team/+archive/ubuntu/stable/
[homebrew]: https://brew.sh/ [homebrew]: https://brew.sh/
[issue #3201]: https://dev.deluge-torrent.org/ticket/3201
[windows forum]: https://forum.deluge-torrent.org/viewforum.php?f=12
[macos forum]: https://forum.deluge-torrent.org/viewforum.php?f=13 [macos forum]: https://forum.deluge-torrent.org/viewforum.php?f=13
[depends]: ../depends.md [depends]: ../depends.md

View File

@ -6,7 +6,7 @@ pyxdg
pillow pillow
mako mako
setuptools setuptools
chardet chardet==4.0.0
setproctitle setproctitle
pywin32; sys_platform == 'win32' pywin32; sys_platform == 'win32'
certifi; sys_platform == 'win32' certifi; sys_platform == 'win32'
@ -14,4 +14,4 @@ windows-curses; sys_platform == 'win32'
zope.interface>=4.4.2 zope.interface>=4.4.2
distro; 'linux' in sys_platform or 'bsd' in sys_platform distro; 'linux' in sys_platform or 'bsd' in sys_platform
pygeoip pygeoip
https://github.com/pydron/ifaddr/archive/37cb5334f392f12811d38d90ec891746e3247c76.zip ifaddr==0.2.0