From df6884437fb6d5cf96890bfe7506c4053744ba5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 5 Dec 2023 15:38:33 +0100 Subject: [PATCH 1/4] Patch download location after move from /home/yunohost.transmission to /home/yunohost.app --- manifest.toml | 1 + scripts/_common.sh | 27 +++++++++++++++++++++++++++ scripts/upgrade | 7 +++++++ 3 files changed, 35 insertions(+) diff --git a/manifest.toml b/manifest.toml index 06d3eaf..3a115d3 100644 --- a/manifest.toml +++ b/manifest.toml @@ -49,6 +49,7 @@ ram.runtime = "50M" [resources.permissions] main.url = "/" + rpc.url = "/transmission/rpc" rpc.allowed = "visitors" rpc.show_tile = false diff --git a/scripts/_common.sh b/scripts/_common.sh index dfb9f1c..71bc4ff 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -51,6 +51,33 @@ _save_and_revert_rpc_password_hash_to_password() { } +_patch_download_locations() { + # First check if patching is required... + if ! grep -R /home/yunohost.transmission /var/lib/transmission-daemon/info/resume >/dev/null; then + return + fi + + rpc_url="http://127.0.0.1:${port}${path_less}transmission/rpc" + + mapfile -t stopped_torrents < <( + transmission-remote "$rpc_url" -l \ + | awk -F '[[:space:]][[:space:]]+' '{if ($9 == "Stopped") print $2;}' + ) + + for torrent in "${stopped_torrents[@]}"; do + # Remove trailing '*' error marker + torrent="${torrent%\*}" + location=$( + transmission-remote "$rpc_url" -t $torrent -i | grep Location: | awk -F ': ' '{print $2}' + ) + newlocation=$( + echo "$location" | sed -e 's|yunohost.transmission|yunohost.app/transmission|' + ) + transmission-remote "$rpc_url" -t "$torrent" --find "$newlocation" + transmission-remote "$rpc_url" -t "$torrent" --verify + done +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 4e94bb5..f291232 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -120,6 +120,13 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_systemd_action --service_name=transmission-daemon --action="start" --log_path="systemd" +#================================================= +# PATCH DOWNLOAD LOCATION IF DOWNLOAD PATH CHANGED +#================================================= +ynh_script_progression --message="Patching download locations..." --weight=1 + +_patch_download_locations + #================================================= # END OF SCRIPT #================================================= From a81f18bf94a1fac6ed1793aa64d37ca4c7226c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 8 Dec 2023 14:03:15 +0100 Subject: [PATCH 2/4] bump package revision --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 3a115d3..6c1540d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Transmission" description.en = "Fast, Easy, and Free BitTorrent Client" description.fr = "Client BitTorrent libre et rapide" -version = "3.00~ynh4" +version = "3.00~ynh5" maintainers = [] From 064214c9301501816402c9a7731fe782c4b0dd51 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 8 Dec 2023 13:03:21 +0000 Subject: [PATCH 3/4] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dbf16b1..2f3c37d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Transmission is a fast, easy, and free BitTorrent client. * Integration with YunoHost Multimedia directories -**Shipped version:** 3.00~ynh4 +**Shipped version:** 3.00~ynh5 ## Screenshots diff --git a/README_fr.md b/README_fr.md index f449eb2..4fadf34 100644 --- a/README_fr.md +++ b/README_fr.md @@ -23,7 +23,7 @@ Transmission est un client BitTorrent libre, efficace et simple. * Intégration avec les répertoires Multimédias de YunoHost -**Version incluse :** 3.00~ynh4 +**Version incluse :** 3.00~ynh5 ## Captures d’écran From 727aabfe0da9e00775e2c83714ed0710e6d18de2 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Mon, 11 Dec 2023 13:42:08 +0100 Subject: [PATCH 4/4] Update upgrade: `rm` on a non-existing file miserably crash the upgrade --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index f291232..234cc8d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,8 +68,8 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=3 # Remove possibly dangling symlinks created before the /home/yunohost.transmission -> /home/yunohost.app/transmission transition # Use rm because ynh_secure_remove fails on dangling symlinks, see https://github.com/YunoHost/issues/issues/2253... -rm "$MEDIA_DIRECTORY/share/Torrents" -rm "$MEDIA_DIRECTORY/share/Torrent to download" +rm "$MEDIA_DIRECTORY/share/Torrents" || true +rm "$MEDIA_DIRECTORY/share/Torrent to download" || true ynh_multimedia_build_main_dir