Commit Graph

9090 Commits

Author SHA1 Message Date
Calum Lind e24081a17e
[CI] Bump Pyinstaller version for Windows packaging
Pyinstaller was pinned due to problems with v5 but these should now be
resolved with latest version.

Bump Twisted to latest minor version

Closes: https://github.com/deluge-torrent/deluge/pull/435
2023-09-18 19:56:31 +01:00
Calum Lind 6c9b058d81
[CI/CD] Fix Pillow packaging build errors
Pillow have dropped 32-bit wheels from v10 onwards so force install of
older v9 wheels since we don't want to build from src.

Refs: https://github.com/python-pillow/Pillow/issues/6941#issuecomment-1604058002
2023-09-18 14:55:53 +01:00
Calum Lind 18dca70084
[GTKUI] Fix cairo crashes by not storing current context
Windows users have reported Deluge crashes when resizing the window with
Piecesbar or Stats plugins enabled:

    Expression: CAIRO_REFERENCE_COUNT_HAS_REFERENCE(&surface->ref_count)

This is similar to issues fixed in GNU Radio which is a problem due to
storing the current cairo context which is then being destroyed and
recreated within GTK causing a reference count error

Fixes: https://dev.deluge-torrent.org/ticket/3339
Refs: https://github.com/gnuradio/gnuradio/pull/6352
Closes: https://github.com/deluge-torrent/deluge/pull/431
2023-09-18 14:55:38 +01:00
Calum Lind ed1366d5ce
[Docs] Fix readthedocs builds
Requires using updated configuration with git unshallow so that version
can be identified from git tags.

Closes: https://github.com/deluge-torrent/deluge/pull/434
2023-09-18 13:00:59 +01:00
Calum Lind 7082d9cec4
[CI] Fix packaging errors with Python 3.7
The latest Pillow 10 does not support Py3.7 therefore wheels are no
longer available and we need to specify previous major version.

Older versions of setuptools do not correctly determine the Twisted
requirement for zope.interface>5 on Python 3.7 so ensure latest
installed. For the CD builds we don't want any surprises so keep the
setuptools version pinned.

Refs: https://pillow.readthedocs.io/en/stable/installation.html
Closes: https://github.com/deluge-torrent/deluge/pull/433
2023-09-18 13:00:43 +01:00
Calum Lind 015b0660be
[CI] Remove chardet version constraint
The version was pinned due to issues with Python 3.10.5 in CI but with
latest versions of Python 3.10 this no longer seems to be an issue.
2023-09-18 11:37:04 +01:00
DjLegolas a459e78268
[UI][Common] Add support for BitTorrent V2 file tree
In BEP52, a new tiles structure was introduce, a `file tree`.
This change added support for this structure in the `TorrentInfo` class.

Ref: https://www.bittorrent.org/beps/bep_0052.html
Closes: https://github.com/deluge-torrent/deluge/pull/404
2023-08-27 11:35:43 +01:00
doadin 8001110625
[Packaging] Fix NSIS Uninstaller Not Removing File\Folder
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Website.lnk" "$INSTDIR\homepage.url"

gets made in the installer but the uninstaller was looking for

 Delete "$SMPROGRAMS\$StartMenuFolder\Deluge Website.lnk"

therefore this file was being left behind and since the folder was not empty

$StartMenuFolder\Deluge

was being left behinde as well.

Closes: https://github.com/deluge-torrent/deluge/pull/426
2023-05-30 19:50:23 +01:00
Calum Lind d8b586e6ba
[CI] Bump image and action versions
Updated the core dump storage to be enabled only when needed.
Fixed missing catchsegv on Ubuntu 22.04 by installing glibc-tools
2023-05-30 19:45:57 +01:00
Calum Lind 905a7dc3bc
[Tests] Only pin libtorrent for tests
Bump versions for Windows packaging
2023-05-30 17:11:13 +01:00
bendikro 89b79e4b7f
[Core] Fix bug when emiting event in EventManager
In some cases, when emiting events with EventManager.emit_event(), the underlying
dictionary of interested sessions can change during iteration, causing:
RuntimeError: dictionary changed size during iteration

Fix by iterating over a copy of the dictionary.

Closes: https://dev.deluge-torrent.org/ticket/3351
Closes: https://github.com/deluge-torrent/deluge/pull/425
2023-05-29 13:57:02 +01:00
bendikro e70e43e631
[GTKUI] Add torrent dialog incorrectly removes dir
When adding a torrent in the add torrents dialog, containing only
a single directory with a single file inside, the directory is not
included as a prefix to the filename.
The prefix is added only if there are multiple files inside the directory.

Fix by adding the prefix also when there is only one file inside a dir.

Closes: https://dev.deluge-torrent.org/ticket/3602
Closes: https://github.com/deluge-torrent/deluge/pull/424
2023-05-29 13:15:43 +01:00
Calum Lind b24a5d2465
[Tests] Ignore pytest temp dir 2023-05-29 12:10:47 +01:00
Calum Lind 701f68d70b
[Tests] Pin libtorrent version to 2.0.7
With latest libtorrent 2.0.9 testing are erroring out so pin
to older working version.

Ref: https://dev.deluge-torrent.org/ticket/3603
2023-05-29 12:10:00 +01:00
Calum Lind de570ae536
[Tests] Fix waiting for lt alert state change
Tests are fragile when waiting for lt alert so allow incrementally
waiting for status change, along with a timeout.
2023-05-29 12:08:39 +01:00
Calum Lind 40a66278a3
[Common] Replace pkg_resources with importlib for resource path finding
With an existing Deluge package installed on the system errors were
occuring trying to start a development instance in virtualenv.

Fixed by replacing usage of deprecated pkg_resource for finding
non-python data files. Includes fallback for Python 3.7/3.8 but drops
Python 3.6 support.

The plugins are still using pkg_resources since they are distributed as
eggs and importlib extracts those data files differently to
pkg_resources so requires a different solution, either as a file stream
or manually cached when plugins are installed.

Closes: https://github.com/deluge-torrent/deluge/pull/403

Co-authored-by: DjLegolas <djlegolas@protonmail.com>
2023-05-29 12:08:34 +01:00
Unit 193 366cded7be
[GTKUI] Enable appindicator support by default
On GNOME, I don't believe any tray icon or indicator support is enabled
by default, but one can easily install an extension for indicators
whereas I'm not sure about tray icons, but the 'top icons' extension I
believe has had a flaky history. I'm not entirely sure how KDE handles
things, but out of the box it too has indicator support and I believe
that is preferred with the move to Wayland. In Xfce, the tray icon area
is called "Status tray" and has support for both tray icons and
indicators.

Closes: https://github.com/deluge-torrent/deluge/pull/318
2023-04-23 18:15:52 +01:00
Calum Lind dbedf7f639
[GTK3] Fix missing AppIndicator option in Preferences
Issue with legacy tray icon being used despite AyatanaAppIndicator3
installed. The problem is due to option to use AppIndicator not being
shown in Preferences.

Fixes: https://dev.deluge-torrent.org/ticket/3598
2023-04-23 18:15:52 +01:00
Xuefer 81116a63ca
[WebUI] use rational maxValue
Signed-off-by: Xuefer <xuefer@gmail.com>
Closes: https://github.com/deluge-torrent/deluge/pull/422
2023-04-23 18:15:51 +01:00
Xuefer H a83ac65ab6
[WebUI] Sidebar: fix error for lazy init
When sidebar is hidden at WebUI startup, header isn't created yet.

Signed-off-by: Xuefer H <xuefer@gmail.com>
Closes: https://github.com/deluge-torrent/deluge/pull/419
2023-04-23 17:30:55 +01:00
Xuefer H d2a56ce15e
[WebUI] FilesTab: undefined setColumnValue
setColumnValue was removed

Signed-off-by: Xuefer H <xuefer@gmail.com>
Closes: https://github.com/deluge-torrent/deluge/pull/417
2023-04-23 17:29:45 +01:00
Xuefer H 71b634e968
[WebUI] use setTimeout instead of setInterval
When server is busy or the request is slow for big file list, WebUI still
requests for new update blindly. "Connection lost" is often triggerd.

Change to only ask for update 2s after reponse (either success or error)

Signed-off-by: Xuefer H <xuefer@gmail.com>
Closes: https://github.com/deluge-torrent/deluge/pull/416
2023-04-23 17:29:06 +01:00
Calum Lind 39bd97f03e
[Core] Fix getting libtorrent alert type
Encountered a problem with dht_error alert not returning the correct
alert name using Python type.

This should likely be fixed in libtorrent but we should be using
the alert.what method to determine alert type/name.

Since the alert name does not include the `_alert` suffix, strip this
when registering alerts.
2023-03-07 16:18:50 +00:00
Calum Lind 196086c1fb
[Core] Refactor alert handler for readability 2023-03-07 16:05:17 +00:00
Chase Sterling 527cfa586c
[Tests] Autorun async tests with pytest_twisted.
Since all of our async tests should be run with twisted, it's
annoying to have to decorate them with pytest_twisted.ensureDeferred.
Forgetting to do this will cause the test to pass without actually
running. This changes the behavior to detect all coroutine function
tests and mark them to be run by pytest_twisted the same way the
decorator does.

Closes: https://github.com/deluge-torrent/deluge/pull/414
2023-03-07 09:24:46 +00:00
DjLegolas 25a2b113e2
[Component] Add pause and resume events methods
For future use add ability to handle pause and resume events

Co-authored-by: Calum Lind <calumlind+deluge@gmail.com>
2023-03-06 13:25:18 +00:00
Calum Lind c38b4c72d0
[Tests] Refactor component tests for readability
Modified test functions to be async.

Used pytest_twisted_ensuredeferred_for_class decorator to avoid needed
ensureDeferred for each test within the class. There might be a way to
do this with fixtures so likely to be improvements for use in all test
classes.

Used Mock in component subclass for simpler tracking of event method calls
2023-03-06 13:25:00 +00:00
DjLegolas 0745c0eff8
[Component] Refactor to remove hasattr usage
Functions are defined in the class now

https://github.com/deluge-torrent/deluge/pull/221#discussion_r228275050
2023-03-06 13:20:14 +00:00
Calum Lind e90f6c7eef
[Tests] Use tmp_path for test logfile
Daemon logfile were being stored in dir where tests were started from
which cluttered up local dev env.

Entry point logfiles are stored in config dir since getting tmp_path in
set_up was a bit too tricky.
2023-03-03 15:57:46 +00:00
Calum Lind 7b1a0ef89c
[Tests] Fix error in TestJSONRequestFailed test
Fix test generating following error

    'TestJSONRequestFailed' object has no attribute 'core'
2023-03-03 15:18:47 +00:00
Calum Lind 75b27485e1
Add metainfo.xml to gitignore 2023-03-03 10:46:31 +00:00
Calum Lind a64cdfaf78
[GtkUI] Enable remapping of keyboard shortcuts
With key shortcuts set in the glade files it is not easy to change
the shortcuts on macOS.

Add AccelPaths to each MenuItem to allow adding or modifying accelerator
in codes. Uses the recommended format `<Deluge-MainWindow>/MenuName`

Update menubar code to use new functionality, taking advantage of
accelerator_parse to specify accelerators as strings instead of Gdk
flags.

A future idea would be to use `Gtk.AccelMap.load` to have shortcuts
loaded from user config.

Co-authored-by: Gregorio Litenstein <g.litenstein@gmail.com>
2023-03-03 10:42:29 +00:00
Calum Lind 4b6ac1f4c4
[WebUI] Fix setting base path
Simplify the code for setting the base path, both via headers and
config. Replaced putchild since it is not recommended for dynamic
paths and overriding getChildWithDefault provides a proper solution.

This also fixes recursive base path problem with previous code where
appending base paths to URL would still return Deluge web e.g.

    http://localhost:8112/deluge/deluge/deluge

Removed getChild override by consolidating empty path conditional to
getChildWithDefault. This simplifies and combines the returning of
TopLevel resource for root path or base path.

Added workaround for test logfile error with forwardslash in filename
2023-03-03 09:37:46 +00:00
Calum Lind 683a4f906e
[WebUI] Minor refactoring
Simplify getting port for WebUI tests
Extract adding slashes to base to function
Use super function to simplify parent class calls
2023-03-03 09:37:36 +00:00
Calum Lind e70a983a55
[Tests] Fix save_resume_data errors in test_torrent
Error in test_rename_unicode:

   TypeError: object MagicMock can't be used in 'await' expression

Fixed by using AsyncMock that can be awaited.
Added backport asyncmock for Python 3.7
2023-02-28 15:05:52 +00:00
Calum Lind 9ce8afe507
[Tests] Fix component warning in Plugin tests
The component fixture was warning about existing registered components since
the standalone client was setup before the componentregistry test was performed.
The problem is due to fixture ordering with the setup fixture running
first since it was marked with autouse followed by component fixture.

* Fixed warning by moving component fixture as a dependency of the set_up fixture
* Cleaned up unneeded code
* Added try..except to catch CorePluginBase KeyError deregistering
RPCServer since component fixture already removed it.
* Ignore test-specific Twisted readBody warnings
2023-02-28 14:21:18 +00:00
Calum Lind f67fb4d520
[Tests] Remove unneeded component teardown
The component fixture calls shutdown so teardown not needed here
2023-02-28 14:20:09 +00:00
Calum Lind d00068423f
[Tests] Ignore 3rd-party deprecation warnings in pytest
Move pytest config from tox to pyproject and ignore deprecation warning
generated in 3rd-party libraries.

Fixed GObject deprecation warning
2023-02-27 20:15:12 +00:00
DjLegolas 7336877928
[console] Fix host deletion
The host id didn't receive correctly and the indexing was not being
updated correctly.

Closes: https://github.com/deluge-torrent/deluge/pull/393
2023-02-27 17:39:00 +00:00
DjLegolas 543fce4f29
[console] Fix add host in connection manager
The input is being passed as `str` instead of `int`, so added a
conversion only if the string is indeed a decimal number.
In addition, closing the add host popup after adding it.

Closes: https://dev.deluge-torrent.org/ticket/3538
2023-02-27 17:39:00 +00:00
DjLegolas 38feea0fa4
[hostlist] Add port value validation
When in console, and adding a new host with an invalid port number, the
console starts printing many exceptions regarding the value.
Therefor, we will make sure that the port value is between 0 and 65535.
2023-02-27 17:39:00 +00:00
Calum Lind 7af584d649
[Console] Refactor Eventlog for readability 2023-02-27 17:39:00 +00:00
Calum Lind 1ba7beb7bc
[Console] Move migration func out of main 2023-02-27 17:38:59 +00:00
Calum Lind f4f4accd34
[Console] Move eventlog class to separate file 2023-02-27 17:38:59 +00:00
Calum Lind ae22a52f2f
[Console] Refactor callbacks and cleanup main 2023-02-27 17:38:59 +00:00
Calum Lind 22f74b60ce
[Console] Cleanup terminal resize handler
Improve readability

Move imports available on Windows out of try..except.

For future reference in Python 3.11 termios now has window size methods
but the added complexity of handling older Python versions is not worth
it.

https://docs.python.org/3/library/termios.html#termios.tcgetwinsize
2023-02-27 17:38:58 +00:00
Calum Lind 253eb2240b
[Console] Refactor main to use async instead of callbacks
Use the new maybe_coroutine decorator to replace callbacks with inline
async/await for cleaner code.
2023-02-27 17:38:58 +00:00
DjLegolas 6c924e6128
[GTK] Fix Add-torrent-dialog not respecting dirs
When adding a new torrent, there is a problem changing the path on
Windows machines, due to the difference between the way the files are
being read from the torrent and how we handle them in addtorrentdialog.
This effects both changing and showing the files in the UI.

Now, all path seperator is being considered and converted to slash '/'.

Closes: https://dev.deluge-torrent.org/ticket/3541
Closes: https://github.com/deluge-torrent/deluge/pull/395
2023-02-24 15:17:38 +00:00
Calum Lind 930cf87103
[Lint] Update pre-commit apps to latest versions
Also update github CI action versions
2023-02-24 14:59:15 +00:00
Calum Lind 45c9f3b90a
[Lint] Fix pre-commit isort install error
Update to latest version of isort to fix install error:

    RuntimeError: The Poetry configuration is invalid:
        - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

Also update the Linting CI to latest version
2023-02-24 14:58:26 +00:00