Commit Graph

9085 Commits

Author SHA1 Message Date
DjLegolas 5d7b416373
[Core] Stop using libtorrent.add_torrent_params_flags_t
The `libtorrent.add_torrent_params_flags_t` is deprecated and when
`libtorrent` is being compiled without deprecated functionality, we will
fail on `AttributeError`.

Refs: 4947602a2f
Closes: https://dev.deluge-torrent.org/ticket/3581
Closes: https://github.com/deluge-torrent/deluge/pull/407
2023-02-24 10:44:57 +00:00
DjLegolas 4de754328f
[ConsoleUI] remove `deferred` being returned after command
A `return` statement was added in ece31cf for unit testing to work but
this resulted in Deferred printed in console output.

Added a test_start entry point to return the required deferreds while
removing the return from original start entrypoint.

Closes: https://dev.deluge-torrent.org/ticket/3582
Closes: https://github.com/deluge-torrent/deluge/pull/408
2023-02-24 10:43:09 +00:00
DjLegolas c4b9cc7292
[tox] update tox.ini for support for `tox` 4
`tox` 4 now demands that `passenv` parameter will be comma-separated and
not space-seperated.

Closes: https://github.com/deluge-torrent/deluge/pull/409
2023-02-23 17:10:40 +00:00
Ryan Ernst fa750c9fd0
[AutoAdd] Fixes #3515 - check for more torrent decode errors
https://github.com/deluge-torrent/deluge/pull/381 improved the situation
with possible errors during torrent decoding. However, the log message in
https://dev.deluge-torrent.org/ticket/3515 indicates a RuntimeError:

```
Traceback: <class 'RuntimeError'>: unexpected end of file in bencoded string
```

This commit adds RuntimeError to those caught while loading the torrent
to add.

Closes: https://github.com/deluge-torrent/deluge/pull/411
2023-02-23 17:08:48 +00:00
Calum Lind 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
Calum Lind 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
DjLegolas 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
Calum Lind b3d1fd79a8
Update changelog from 2.1.1 release 2022-07-10 14:06:34 +01:00
Calum Lind b64084d248
[Docs] Update changelog and install details 2022-07-08 09:04:57 +01:00
Calum Lind 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
Calum Lind 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
Calum Lind 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
Calum Lind 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
Calum Lind 592b05cd87
back to development 2022-06-28 22:11:29 +01:00
Calum Lind 6c8f9ce756
Release 2.1.0 2022-06-28 22:07:35 +01:00
Calum Lind 19dba297ef
[Docs] Fix ReadTheDocs theme rendering issue
Fix rendering issues in ReadTheDocs by specifying latest version of
sphinx-rtd-theme. Normally not an issue to install this latest
dependency from doc/requirement.txt but RTD installs in the env an older
version (<0.5) before running requirements file install
thus sphinx-rtd-theme is not upgraded unless a version is specified.

See-also: https://github.com/readthedocs/sphinx_rtd_theme/issues/1115
2022-06-28 19:45:21 +01:00
N9199 cbacaf0545
[Core] Fix typo in AUTH_LEVEL_MAPPING
Closes: https://github.com/deluge-torrent/deluge/pull/387
2022-06-19 19:02:11 +01:00
Calum Lind 75db47fc1f
Update Changelog entries 2022-06-19 08:30:54 +01:00
Calum Lind f1ec68704d
[CD] Cleanup pip cache in Win builds
- Use the more reliable setup-python cache
- Move the pip install to GTK install step for consistency
- Don't update pip to ensure consistent version
2022-06-13 19:37:41 +01:00
Martin Hertz ae3fbcca77
[Packaging] Pinned Pyinstaller to v4.10 and readme update
Pin Pyinstaller to latest v4.x until issue of aborting upon missing typelibs for various unbuilt gst-modules can be properly investigated and resolved. Specific error for one of the modules being:

`36738 INFO: Loading module hook 'hook-gi.repository.Gst.py' from 'C:\\hostedtoolcache\\windows\\Python\\3.9.13\\x64\\lib\\site-packages\\PyInstaller\\hooks'...
Traceback (most recent call last):
  File "<string>", line 7, in <module>
gi.repository.GLib.GError: g-irepository-error-quark: Typelib file for namespace 'Gst', version '1.0' not found (0)
36870 ERROR: gi repository 'GIRepository 2.0' not found. Please make sure corresponding package is installed.
Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\gi\__init__.py", line 139, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available`

Added `--no-index` to ensure pip doesn't install from Pypi

Closes: https://github.com/deluge-torrent/deluge/pull/386
2022-06-13 19:31:54 +01:00
Calum Lind 6a10e8f3cd
[Packaging] Bump Win dependencies
* Update Twisted and libtorrent to latest releases
* Update to v3 github actions that now use node 16
2022-06-12 20:05:04 +01:00
ibizaman b0dba97fec
[Web] Accept charset in content-type for json messages
Trac: https://dev.deluge-torrent.org/ticket/3521
Closes: https://github.com/deluge-torrent/deluge/pull/385
2022-06-12 16:08:36 +01:00
Martin Hertz d7c520c85e
[WebUI] Fixed 'Complete Seen' and 'Completed' sorting
Closes: https://github.com/deluge-torrent/deluge/pull/384
2022-05-17 22:45:37 +01:00
Martin Hertz ee3180fd94
[Notifications] Fix UnicodeEncodeError upon non-ascii torrent name
smtplib.SMTP.sendmail expects 'msg' in string of ascii chars or bytes,
where the former gets encoded to bytes through ascii codec, hence
raising said error, but now fixed by encoding to bytes ourself through
utf-8

Closes: https://github.com/deluge-torrent/deluge/pull/383
2022-05-17 22:42:05 +01:00
Chase Sterling 47e548fdb5
[Core] Refactor prefetch_metadata for more clarity
Just trying to clean up some of the more complicated callback logic.

Notable changes:

* The test was awaiting a DeferredList. By default that will eat
exceptions and just add them to the result list (including test
assertion exceptions.) Added fireOnOneErrback=True to make sure that
wasn't happening.  * Moved the logic for multiple calls to await the
same response into torrentmanager from core, so no matter where the
prefetch is called from it will wait for the original call.
* Implemented the multiple calls with an explicit queue of waiting
callbacks, rather than a callback callback chain.  * Moved to one inline
async function rather than split into a main and callback after alert
function.
* Added some more type hints to the stuff I changed.

Adjusted test since we are using prefetch as an async function now
we have to schedule the alert to come after we start awaiting the
prefetch call.

Closes: https://github.com/deluge-torrent/deluge/pull/368
2022-05-17 22:15:55 +01:00
Calum Lind cd63efd935
[Console] Fix curses.init_pair raise ValueError on Py3.10
Fix ValueError crash for console users with Python 3.10

Trac: https://dev.deluge-torrent.org/ticket/3518
See-also: https://docs.python.org/3/whatsnew/3.10.html#curses
2022-05-01 21:09:41 +01:00
Calum Lind 7f0a380576
[Core] Cleanup temp files in add_torrent_url
Temporary torrent files are not deleted by add_torrent_url. Not as big a
problem as with tracker icons pages but should be removed after use.

Fixed by updating the method to use async and a try..finally cleanup
block.

Perhaps could be refactored to not require temporary files and instead
store the downloaded torrent as object for passing to add_torrent_file.

Trac: https://dev.deluge-torrent.org/ticket/3167
2022-05-01 20:38:09 +01:00
Calum Lind 68c75ccc05
[TrackerIcons] Cleanup tmp files created by downloading page
Temporary files created while download host html page are no cleaned up
if the download fails.

Fixed by adding a 'finally' step in the callback chain to delete any
created temporary files.

Added tests to ensure the temporary files are deleted, using a fixture
that creates a known filename for the test.

Trac: https://dev.deluge-torrent.org/ticket/3167
2022-05-01 20:35:28 +01:00
Calum Lind 96a0825add
[TrackerIcon] Use httpdownloader page redirect handling
User reported infinite redirecting when attempting to fetch tracker
icon.

Fixed by allowing httpdownloader and RedirectAgent to handle page
redirects including catching infinite redirects

Trac: https://dev.deluge-torrent.org/ticket/3167
See-also: https://github.com/twisted/twisted/blob/5c24e9/src/twisted/web/client.py#L168
2022-05-01 20:35:28 +01:00
Calum Lind 61a83bbd20
[Tests] Remove winreg interface name check
GitHub CI tests on Windows failing for get_windows_interface_name so
remove the fragile tests since not a requirement to be this specific
with testing whether name exists for these methods relying on standard
lib or 3rd-party libs.
2022-05-01 20:32:57 +01:00
deaddrop9 bc6611fc0d
[AutoAdd] Verify torrent decode and errors cleanly if invalid
Watch folder was disabled in AutoAdd and torrent filename is unchanged
if an invalid torrent was added.

Trac: https://dev.deluge-torrent.org/ticket/3515
Closes: https://github.com/deluge-torrent/deluge/pull/381
2022-05-01 18:34:19 +01:00
DjLegolas 970a0ae240
[lint] update black package
Previous version (22.1.0) didn't support `click` version 8.1.0.
Updating to 22.3.0 to resolve.

See: https://github.com/psf/black/issues/2964
Closes: https://github.com/deluge-torrent/deluge/pull/382
2022-05-01 18:31:12 +01:00
Calum Lind 5acb57b5af
[CI] Use setup-python action pip cache
Replace custom pip cache that didn't work correctly on Windows with
option to use pip cache in setup-python action
2022-03-02 13:08:02 +00:00
DjLegolas 7fa0af3446
[Core] Fixed KeyError in sessionproxy after torrent delete
When several torrents are being removed from session, an exception was
being raised in a callback function `on_status` with the `torrent_id` of
one (or more) of the removed torrents.
Now we will catch when the torrent does not exist anymore and print a
debug log about it.

Closes: https://dev.deluge-torrent.org/ticket/3498
Closes: https://github.com/deluge-torrent/deluge/pull/341
2022-03-02 13:00:45 +00:00
DjLegolas a954348567
[CI] Use libtorrent pypi install
Up until now, the linux installation source of libtorrent was launchpad,
because there was no other source, and we wanted a debug version of lt.

With pypi wheel versions now available use lt in the requirements.txt
file.

Closes: https://github.com/deluge-torrent/deluge/pull/364
2022-03-02 12:55:19 +00:00
DjLegolas 13be64d355
[CI] Changed tested python version to 3.7 and 3.10
We cannot add python 3.6 because there is no precompiled version of it to used.
Therefor, will be using 3.7 as the minimum version in CI.
In addition, dropped version limits from pytest.
2022-03-02 12:53:29 +00:00
Calum Lind 11fe22e4cd
[Tests] Remove reference to Twisted Trial
With the move to pytest remove remainings documentation or comments that
refer to Trial.
2022-03-02 12:45:15 +00:00
Calum Lind a683b7e830
[Tests] Skip SNI icon test
The SNI icon test is failing due to seo.com removing their favicon.

A new test to replace it would be needed to check SNI support. Ideally
new tests would not rely on external sites.
2022-03-02 12:18:05 +00:00
marik b0f80f9654
[Console] Swap j and k key's behavior to fit vim mode
There is a problem in the Deluge's Console UI. This UI supports the j
and k keys as up and down, but for some reason they are inverted. This
commit inverts back the behaviour of j and k in several places.

Resolves: https://dev.deluge-torrent.org/ticket/3483
Closes: https://github.com/deluge-torrent/deluge/pull/377
2022-03-02 11:38:36 +00:00
Calum Lind f9ca3932a8
[GTK] Remove unneeded glade icon activatable False property
This propery cause issue with added extra space in the entries, likely a
minor GTK bug and property being leftover from GTK2 migration. The
default is True and should have no effect since no icon is shown.
2022-03-02 11:29:17 +00:00
Calum Lind 5ec5271fdd
[GTK] Refactor Connection Manager Add Host dialog
Replace table with grid and use single column for entries.
2022-03-02 11:09:30 +00:00
Calum Lind e15731fcd4
[GTK] Fix obscured port number in Connection Manager Add Host
A visual problem with the port spin button meant that the port number
was not fully visible in the entry field.

The problem is related to icon activatable property value set to False
when default is True. Although no icon is used is creates a left-hand
5px space in the entry which narrows the available text space and the
entry does not expand to account for this.

Fixed by removing primary_icon_activatable and
secondary_icon_activatable properies so that default values of True is
used.
2022-03-02 11:02:26 +00:00
Hugo Osvaldo Barrera 2962f7cd2c
[Packaging] Add systemd user services
Files should be installed into /usr/lib/systemd/user/

Unlike the existing service file, this one configures deluge to run as a
desktop session user. The difference between the services files is the
use of multi-user.target in system service which does not exist for user
services so requires default.target.

Including the Slice indicates to the service manager that this is a
background service. This can be used to handle OOM situations, or
prioritising foreground processes. There's no equivalent for system
services.

Refs: https://dev.deluge-torrent.org/ticket/2034
Closes: https://github.com/deluge-torrent/deluge/pull/380
2022-03-02 09:26:23 +00:00
tbkizle c89a366dfb
[Hostlist] Support IPv6 in host lists
socket.gethostbyname does not support IPv6 name resolution, and
getaddrinfo() should be used instead for IPv4/v6 dual stack support.

Closes: https://github.com/deluge-torrent/deluge/pull/376
2022-02-18 23:05:12 +00:00
Calum Lind 5f8acabb81
[Console] Fix torrent details status error
The torrent status num_peers and num_seeds was replaced for session
status keys by accident as part of replacing deprecated session keys
so revert those changes

Ref: 2bd095e5bf
2022-02-17 20:30:05 +00:00
Calum Lind 055a84bb15
[Core] Fix Twisted fromCoroutine AttrError
Users with older versions of Twisted <= 21.2 were encoutering the
following error:

    File "/home/calum/projects/deluge/deluge/decorators.py", line 191, in activate
      d = defer.Deferred.fromCoroutine(self.coro)

    builtins.AttributeError: type object 'Deferred' has no attribute 'fromCoroutine'

Fixed by falling back to ensureDeferred since fromCoroutine was
introduced in Twisted 21.2 as a saner name for handling of coroutines.

Ref: https://twistedmatrix.com/trac/ticket/9825
2022-02-16 16:20:54 +00:00
Calum Lind 03938839e0
[Docs] Add permanent discord invite link
Default discord invites expire after 7 days so replace with non-expiring
invite
2022-02-15 15:30:08 +00:00
Chase Sterling 8ff4683780
Automatically refresh and expire the torrent status cache.
Stop at ratio was not working when no clients were connected, because
it was using a cached version of the torrent status, and never calling
for a refresh. When a client connected, it called for the refresh and
started working properly.

Closes: https://dev.deluge-torrent.org/ticket/3497
Closes: https://github.com/deluge-torrent/deluge/pull/369
2022-02-15 15:14:40 +00:00
Calum Lind 62a4052178
[Docs] Remove custom mock to fix autodoc typing errors
If a libtorrent return type was specified e.g.

   def get_lt_status(self) -> 'lt.torrent_status'

Even as a string autodoc_typehints module would raise and error:

    Handler <function process_docstring at 0x7f6c16c8ec10> for event 'autodoc-process-docstring' threw an exception (exception: getattr(): attribute name must be string)

This was a result of using a custom mock in Sphinx autodoc config and
this Mock object name or qualname returns an object instead of str.

Testing with putting modules in autodoc_mock_imports again showed no
issues so removing custom mock

Ref: https://github.com/tox-dev/sphinx-autodoc-typehints/issues/220
2022-02-15 11:49:54 +00:00
Calum Lind 8ece036770
[WebUI] Move HTML entity encoding to client
We should not be mangling the torrent data in the JSON API since this
can have unintended consquences with names and filepaths that can be
edited. If we escape those symbols in the JSON API then the data no
longer matches that stored by core. Therefore shift the encoding to the
client and consider dealing separetely with these entities when the user
first adds a torrent.

* Created a modified htmlEncode in Deluge Formatter based on extjs
method that also encodes single quotes.
* Removed renderers in ListViews since only templates specified via tpl
are used and any render attribute specified was a no-op.
* Removed old buggy escapeHtml

Resolves: https://dev.deluge-torrent.org/ticket/3459
Ref: https://docs.sencha.com/extjs/6.5.3/modern/src/String.js.html#Ext.String-method-htmlEncode
Ref: https://docs.sencha.com/extjs/3.4.0/source/Format.html#Ext-util-Format-method-htmlEncode
2022-02-14 18:44:19 +00:00