fix(transmission): let incomplete-dir stay off across restarts (#3063)

* fix(transmission): let incomplete-dir stay off across restarts

01-config.sh rewrites Transmission's settings.json on every restart,
deriving "incomplete-dir-enabled" purely from whether incomplete_dir is
non-empty. Since incomplete_dir defaults to a non-empty path, any toggle
made in Transmission's own Web UI was silently overwritten back to enabled
on the next restart (#3059).

Add incomplete_dir_enabled (bool, default true): setting it to false writes
the disabled state on every restart instead of forcing it back on. The
default of true preserves normal existing configurations unchanged; the two
edge cases it also touches were already latent bugs, see below.

While touching this line: bashio::config's own default-value argument
cannot be an empty string (bash's ${2:-null} treats "" as unset), so an
install whose incomplete_dir key was entirely absent, or literally the four
characters "null", returned bashio's own "null" fallback and would have
created a directory named "null". Normalized that explicitly; both now
disable instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(transmission): keep incomplete-dir enabled on upgrade in standalone mode

The previous commit relied on bashio::config's default argument to treat
an absent incomplete_dir_enabled as true. The standalone shim
(.templates/bashio-standalone.sh), injected by 00-banner.sh when the image
runs without Supervisor, ignores that argument and returns "" for a
missing key, so an upgraded standalone install would have silently
disabled its incomplete directory.

Treat anything but an explicit "false" as enabled instead. That covers
real bashio ("null") and the shim ("") alike, and drops the default
argument altogether.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Alexandre
2026-09-13 07:10:57 +02:00
committed by GitHub
parent b88c5c5826
commit 88faf503fb
4 changed files with 21 additions and 3 deletions

View File

@@ -1,3 +1,6 @@
## 4.1.3.1 (2026-09-12)
- Add `incomplete_dir_enabled` (default `true`): set to `false` to permanently disable the incomplete-downloads directory. Restarting the add-on always overwrote Transmission's own Web UI toggle for this back to enabled (#3059); this option is read on every restart instead, so it actually sticks
- Fix a latent bug in the same code: an install where `incomplete_dir` was entirely absent from options (rather than emptied) would create and use a directory literally named `null`
## 4.1.3 (2026-07-04)
- Update to latest version from linuxserver/docker-transmission (changelog : https://github.com/linuxserver/docker-transmission/releases)

View File

@@ -62,6 +62,7 @@ Configurations can be done through the app webUI, except for the following optio
| `TZ` | str | | Timezone (e.g., `Europe/London`) |
| `download_dir` | str | `/share/downloads` | Directory for completed downloads |
| `incomplete_dir` | str | `/share/incomplete` | Directory for incomplete downloads |
| `incomplete_dir_enabled` | bool | `true` | Set to `false` to permanently disable the incomplete-downloads directory. Transmission's own Web UI toggle for this is overwritten on every add-on restart, so use this option instead |
| `watch_dir` | str | | Directory to watch for torrent files |
| `customUI` | list | `flood-for-transmission` | Web UI (standard/transmission-web-control/kettu/flood-for-transmission) |
| `user` | str | | Web UI username |

View File

@@ -87,6 +87,7 @@ options:
customUI: flood-for-transmission
download_dir: /share/downloads
incomplete_dir: /share/incomplete
incomplete_dir_enabled: true
panel_admin: false
panel_icon: mdi:transmission-tower
ports:
@@ -114,6 +115,7 @@ schema:
customUI: list(standard|transmission-web-control|kettu|flood-for-transmission)
download_dir: str
incomplete_dir: str?
incomplete_dir_enabled: bool?
localdisks: str?
networkdisks: str?
pass: str?
@@ -124,4 +126,4 @@ schema:
slug: transmission_ls
udev: true
url: https://github.com/alexbelgium/hassio-addons
version: "4.1.3"
version: "4.1.3.1"

View File

@@ -57,6 +57,15 @@ bashio::log.warning "If UI was changed, you need to clear browser cache for it t
echo "Creating config"
download_dir=$(bashio::config 'download_dir')
incomplete_dir=$(bashio::config 'incomplete_dir')
# bashio::config prints the literal string "null" for an absent option (its
# own default-value argument cannot be an empty string: bash's ${2:-null}
# treats "" the same as unset). Without this, an option missing entirely
# (upgrade from before this key existed) would count as a 4-character dir and
# create one literally named "null"
[ "$incomplete_dir" = "null" ] && incomplete_dir=""
# Enabled unless explicitly false: an absent key reads as "null" in bashio and
# as "" in the standalone shim, which ignores bashio::config's default argument
incomplete_dir_enabled=$(bashio::config 'incomplete_dir_enabled')
CONFIG=$(< $CONFIGDIR/settings.json)
# Permissions
@@ -64,8 +73,11 @@ echo "Updating permissions"
mkdir -p "$download_dir"
chown "$PUID:$PGID" "$download_dir"
# if incomplete dir > 2, to allow both null and '', set it as existing
if [ ${#incomplete_dir} -ge 2 ]; then
# The addon's own toggle wins on every restart, which is the point: Transmission's
# Web UI toggle is overwritten here regardless, so a permanent "off" has to come
# from an option this script reads, not from the Web UI (issue #3059). A dir
# shorter than 2 characters (empty, "/") is treated as unset either way.
if [ "$incomplete_dir_enabled" != "false" ] && [ ${#incomplete_dir} -ge 2 ]; then
echo "Incomplete dir set: $incomplete_dir"
CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir-enabled\"=true")
mkdir -p "$incomplete_dir"