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:
parent
e6c763c8c0
commit
df6884437f
3 changed files with 35 additions and 0 deletions
|
@ -49,6 +49,7 @@ ram.runtime = "50M"
|
||||||
|
|
||||||
[resources.permissions]
|
[resources.permissions]
|
||||||
main.url = "/"
|
main.url = "/"
|
||||||
|
|
||||||
rpc.url = "/transmission/rpc"
|
rpc.url = "/transmission/rpc"
|
||||||
rpc.allowed = "visitors"
|
rpc.allowed = "visitors"
|
||||||
rpc.show_tile = false
|
rpc.show_tile = false
|
||||||
|
|
|
@ -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
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -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"
|
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
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue