From 6768d8f019f5392e083251288c4d135fa19d724a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Apr 2026 06:32:37 +0000 Subject: [PATCH] Fix STORAGE_FOLDER not being recognized by creating symlink from resolved path to persistent location Linkwarden resolves STORAGE_FOLDER via path.join(process.cwd(), '../..', STORAGE_FOLDER) which produces /data_linkwarden/config/library instead of /config/library when the app runs from apps/web or apps/worker subdirectories. The symlink ensures data written to the resolved path ends up in the persistent addon config directory. Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/23af3f23-96f8-49a3-849a-82fb5feef2bc Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- linkwarden/rootfs/etc/cont-init.d/99-run.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/linkwarden/rootfs/etc/cont-init.d/99-run.sh b/linkwarden/rootfs/etc/cont-init.d/99-run.sh index ce2d5f68e..4573654a6 100755 --- a/linkwarden/rootfs/etc/cont-init.d/99-run.sh +++ b/linkwarden/rootfs/etc/cont-init.d/99-run.sh @@ -9,6 +9,25 @@ set -e bashio::log.info "Creating folders" mkdir -p "$STORAGE_FOLDER" +# Linkwarden resolves STORAGE_FOLDER relative to its monorepo root via: +# path.join(process.cwd(), '../..', STORAGE_FOLDER, filePath) +# When the app runs from /data_linkwarden/apps/web, an absolute STORAGE_FOLDER +# (e.g. /config/library) is resolved to /data_linkwarden/config/library instead +# of /config/library. Create a symlink so data reaches the persistent location. +if [[ "$STORAGE_FOLDER" == /* ]]; then + RESOLVED_STORAGE="/data_linkwarden${STORAGE_FOLDER}" + if [ "$RESOLVED_STORAGE" != "$STORAGE_FOLDER" ]; then + mkdir -p "$(dirname "$RESOLVED_STORAGE")" + # Preserve any data already written to the non-persistent path + if [ -d "$RESOLVED_STORAGE" ] && [ ! -L "$RESOLVED_STORAGE" ]; then + cp -rn "$RESOLVED_STORAGE/." "$STORAGE_FOLDER/" 2>/dev/null || true + rm -rf "$RESOLVED_STORAGE" + fi + ln -sfn "$STORAGE_FOLDER" "$RESOLVED_STORAGE" + bashio::log.info "Symlinked $RESOLVED_STORAGE -> $STORAGE_FOLDER" + fi +fi + ###################### # CONFIGURE POSTGRES # ######################