Compare commits

...

11 Commits

Author SHA1 Message Date
2a945de069 [CI] Fix tests stalling/timing out
GitHub pytest runner stalling with the following error:

    [Errno 2] No such file or directory: '/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/deluge/plugins'

This is related to the editable install of Deluge via pip

    pip install -e .

and the custom resource_filename in deluge.common is the source of the
problem where a DistInfoDistribution returns a different path to
EggInfoDistribution.

Working egg-info install

    >>> pkg_resources.get_distribution('Deluge')
    deluge 2.1.1.dev8 (/home/user/deluge)

    >>> type(pkg_resources.get_distribution('Deluge'))
    <class 'pkg_resources.EggInfoDistribution'>

    >>> pkg_resources.resource_filename('deluge', 'plugins')
    '/home/user/deluge/deluge/plugins'

This can identified by the `deluge.egg-info` directory in source
directory.

Broken dist-info install

    >>> pkg_resources.get_distribution('Deluge')
    deluge 2.1.1.dev8 (/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages)

    >>> type(pkg_resources.get_distribution('Deluge'))
    <class 'pkg_resources.DistInfoDistribution'>

    >>> pkg_resources.resource_filename('deluge', 'plugins')
    '/home/user/deluge/deluge/plugins'

This can be worked around by setting an env var that enables legacy mode
but long-term need to replace the custom resource_filename and replace
usage of pkg_resources.

https://setuptools.pypa.io/en/latest/userguide/development_mode.html#legacy-behavior
https://setuptools.pypa.io/en/latest/pkg_resources.html
2022-12-01 22:39:10 +00:00
d0acd3e06e [CI] Fix installing enchant for github docs workflow
The enchant package was renamed for version 2 to enchant-2 and original
enchant package removed in Ubuntu 22.04 so docs workflow failed

Fixed by using latest package and specifying ubuntu version to avoid
unexpected failures in future.
2022-12-01 13:11:53 +00:00
3565a9a817 [WebUI] Fix TypeError in DelugeWeb constructor
In `twisted 22.10`, a check new for passing the `path` variable as
`bytes` in the `putChild` method.
We were enforcing this on every other place but the `__init__` of
`DelugeWeb` itself.

Ref: https://github.com/twisted/twisted/pull/11718
Closes: https://dev.deluge-torrent.org/ticket/3566
2022-12-01 12:52:00 +00:00
b3d1fd79a8 Update changelog from 2.1.1 release 2022-07-10 14:06:34 +01:00
b64084d248 [Docs] Update changelog and install details 2022-07-08 09:04:57 +01:00
e120536d87 Fix parsing magnet with tracker tiers
Magnets with trackers specified with tr.x param were not being unquoted
so unusable raw tracker string was being set.

Fixed by unquoting tracker and adding test

See-also: https://dev.deluge-torrent.org/ticket/2716
2022-07-08 08:34:29 +01:00
f52cf760e4 Fix missing trackers adding magnets
The changes to remove deprecated lt methods didn't account for magnet
trackers so magnets are missing trackers when added.

Previously the addition of trackers was handled by libtorrent when a url
was passed in add_torrent_params. The url parameter is deprecated so
instead we need to add both the info_hash and trackers.

Trac: https://dev.deluge-torrent.org/ticket/3530
2022-07-05 08:03:33 +01:00
94d790c159 [CI] Bump ifaddr to 0.2.0
With release of ifaddr 0.2.0 no longer need to pin to github commit to
resolve Windows decoding issues.
2022-06-30 21:47:06 +01:00
f78506161d [CI] Fix failing Windows Python 3.10 tests
A recent dependency change caused the tests running on GitHub Actions
under Python 3.10.5 on Windows to fail when starting pytest run:

    ...
    INTERNALERROR>   File "<frozen importlib._bootstrap>", line 123, in acquire
    INTERNALERROR> KeyError: xxxx

The cause seems to have been a newer version of chardet package released
recently.

* Fixed by pinning chardet to v4
* Also pin Windows version to 2019 to match packaging workflow

See-also: https://github.com/deluge-torrent/deluge/actions/runs/2578427588
Issue: https://github.com/chardet/chardet/issues/265
2022-06-29 15:07:23 +01:00
592b05cd87 back to development 2022-06-28 22:11:29 +01:00
6c8f9ce756 Release 2.1.0 2022-06-28 22:07:35 +01:00
10 changed files with 55 additions and 31 deletions

View File

@ -7,6 +7,9 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
jobs:
test-linux:
runs-on: ubuntu-20.04
@ -65,7 +68,7 @@ jobs:
path: /cores
test-windows:
runs-on: windows-latest
runs-on: windows-2019
strategy:
matrix:
python-version: ["3.7", "3.10"]

View File

@ -36,7 +36,7 @@ jobs:
run: |
pip install --upgrade pip wheel
pip install tox
sudo apt-get install enchant
sudo apt-get install enchant-2
- name: Test with tox
env:

View File

@ -1,11 +1,21 @@
# Changelog
## 2.1.0 (WIP)
## 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)
### Breaking changes
- Python 2 support removed (Python >= 3.6)
- libtorrent minimum requirement increased (>= 1.2).
### Core
- Drop Python 2 support for Python 3 only.
- Set libtorrent minimum required version to 1.2.
- Add support for SVG tracker icons.
- Fix tracker icon error handling.
- Fix cleaning-up tracker icon temp files.

View File

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

View File

@ -436,8 +436,8 @@ class TorrentManager(component.Component):
magnet_info = get_magnet_info(magnet)
if magnet_info:
add_torrent_params['name'] = magnet_info['name']
add_torrent_params['trackers'] = list(magnet_info['trackers'])
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))
else:
raise AddTorrentError(

View File

@ -7,6 +7,7 @@
import os
import sys
import tarfile
from urllib.parse import quote_plus
import pytest
@ -19,6 +20,7 @@ from deluge.common import (
fsize,
fspeed,
ftime,
get_magnet_info,
get_path_size,
is_infohash,
is_interface,
@ -209,3 +211,16 @@ class TestCommon:
if tar_info.name == 'archive_message.txt':
result = tar.extractfile(tar_info).read().decode()
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
def test_add_torrent_magnet(self):
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 = {}
torrent_id = yield self.core.add_torrent_magnet(uri, options)
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):
tid1 = self.add_torrent('test.torrent', paused=True)

View File

@ -682,7 +682,7 @@ class DelugeWeb(component.Component):
if self.base != '/':
# Strip away slashes and serve on the base path as well as root path
self.top_level.putChild(self.base.strip('/'), self.top_level)
self.top_level.putChild(self.base.strip('/').encode(), self.top_level)
setup_translation()

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
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
@ -96,15 +96,6 @@ The [development PPA] contains daily builds from the `develop` branch.
sudo add-apt-repository -u ppa:deluge-team/develop
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
#### Unofficial `.app` packages
@ -138,7 +129,5 @@ sudo port install deluge
[development ppa]: https://launchpad.net/~deluge-team/+archive/ubuntu/develop/
[stable ppa]: https://launchpad.net/~deluge-team/+archive/ubuntu/stable/
[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
[depends]: ../depends.md

View File

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