From 2cd2f9c443b8fd02e99392bcfd60a6db87568b3a Mon Sep 17 00:00:00 2001 From: dlynas <118506937+dlynas@users.noreply.github.com> Date: Tue, 5 May 2026 00:46:45 -0400 Subject: [PATCH 1/2] fix: skip recursive chown on startup when UIDs are already correct The unconditional chown -R on every container start was walking the entire /app tree (including large music libraries) even when nothing needed fixing. Now only the directory nodes themselves are chowned at startup; the recursive walk still runs inside the UID-change branch where it is actually needed. Co-Authored-By: Claude Sonnet 4.6 --- entrypoint.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1c9f1382..49c99f9c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -63,9 +63,11 @@ echo " 📄 Updating settings.py to current version..." cp /defaults/settings.py /app/config/settings.py chown soulsync:soulsync /app/config/settings.py 2>/dev/null || true -# Ensure all directories exist and have proper permissions +# Ensure all directories exist with correct ownership. +# Only the directory nodes themselves need chown here — the recursive chown +# above already ran if UIDs changed, so avoid walking the whole tree every start. mkdir -p /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging -chown -R soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging 2>/dev/null || true +chown soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging 2>/dev/null || true echo "✅ Configuration initialized successfully" From e4bdb8bc17e6283fdf44e851d2b8eca5fd494250 Mon Sep 17 00:00:00 2001 From: dlynas <118506937+dlynas@users.noreply.github.com> Date: Tue, 5 May 2026 02:05:26 -0400 Subject: [PATCH 2/2] fix: skip recursive chown when data directory ownership already matches After the first startup the data directories are already owned by the correct PUID:PGID. Subsequent restarts now stat /app/data and skip the expensive recursive walk when ownership is already correct, even when PUID/PGID differ from the image defaults. Co-Authored-By: Claude Sonnet 4.6 --- entrypoint.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 49c99f9c..8bbf43d8 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -35,9 +35,15 @@ if [ "$CURRENT_UID" != "$PUID" ] || [ "$CURRENT_GID" != "$PGID" ]; then usermod -o -u "$PUID" soulsync fi - # Fix ownership of app directories - echo "🔒 Fixing permissions on app directories..." - chown -R soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging 2>/dev/null || true + # Only do the expensive recursive chown if the data directory ownership + # doesn't already match — avoids walking large libraries on every restart. + DATA_OWNER=$(stat -c '%u:%g' /app/data 2>/dev/null || echo "unknown") + if [ "$DATA_OWNER" != "$PUID:$PGID" ]; then + echo "🔒 Fixing permissions on app directories..." + chown -R soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging 2>/dev/null || true + else + echo "✅ App directory permissions already correct" + fi else echo "✅ User/Group IDs already correct" fi