1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/transmission_ynh.git synced 2024-09-04 01:46:12 +02:00

Patch download location after move from /home/yunohost.transmission to /home/yunohost.app

This commit is contained in:
Félix Piédallu 2023-12-05 15:38:33 +01:00 committed by Félix Piédallu
parent e6c763c8c0
commit a6a54980b9
2 changed files with 31 additions and 0 deletions

View file

@ -51,6 +51,30 @@ _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"
stopped_torrents=$(
transmission-remote "$rpc_url" -l \
| awk -F '[[:space:]][[:space:]]+' '{if ($5 == "Stopped") print $2;}'
)
for torrent in "${stopped_torrents[@]}"; do
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 http://127.0.0.1:9091/torrent/transmission/rpc -t "$torrent" --find "$newlocation"
done
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

View file

@ -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
#=================================================