diff --git a/Dockerfile.nas b/Dockerfile.nas index 9aaa307..3689aad 100644 --- a/Dockerfile.nas +++ b/Dockerfile.nas @@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* # Joplin Terminal (official npm package) -RUN npm install --loglevel=error -g joplin +RUN npm install --loglevel=error -g joplin@3.7.1 WORKDIR /app COPY pyproject.toml requirements.txt ./ diff --git a/nas/run_once.sh b/nas/run_once.sh index 9b9406e..6a94847 100644 --- a/nas/run_once.sh +++ b/nas/run_once.sh @@ -7,6 +7,31 @@ RESULT_JSON="/app/data/last_result.json" log() { printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$*"; } fail() { log "ERROR: $*"; exit 1; } +joplin_sync() { + local tmp + local status + + tmp="$(mktemp)" + + set +e + joplin --profile "$PROFILE" sync 2>&1 | tee "$tmp" + status=${PIPESTATUS[0]} + set -e + + if [[ "$status" -ne 0 ]]; then + rm -f "$tmp" + fail "Joplin sync failed with exit code $status" + fi + + if grep -Eqi 'Last error:|(^|[[:space:]])Error:' "$tmp"; then + log "ERROR: Joplin reported a sync error:" + grep -Ei 'Last error:|(^|[[:space:]])Error:' "$tmp" || true + rm -f "$tmp" + exit 1 + fi + + rm -f "$tmp" +} : "${JOPLIN_WEBDAV_URL:?JOPLIN_WEBDAV_URL is required}" : "${JOPLIN_WEBDAV_USERNAME:?JOPLIN_WEBDAV_USERNAME is required}" @@ -33,7 +58,7 @@ fi # Pull the current remote state first. This is important when PC/mobile also use the same WebDAV target. log "Synchronising Joplin from WebDAV before writing..." -joplin --profile "$PROFILE" sync +joplin_sync if [[ "${JOPLIN_WRITE_ENABLED,,}" != "true" ]]; then log "JOPLIN_WRITE_ENABLED=false: sync-only safety mode. No paper note will be written." @@ -86,6 +111,6 @@ log "Importing report into Joplin notebook: $JOPLIN_NOTEBOOK" joplin --profile "$PROFILE" import "$TMP_MD" "$JOPLIN_NOTEBOOK" --format md -f log "Synchronising Joplin changes to WebDAV..." -joplin --profile "$PROFILE" sync +joplin_sync log "Completed: $REPORT_TITLE ($REPORT_COUNT papers)" diff --git a/state/provider_circuit_breaker_state.json b/state/provider_circuit_breaker_state.json index 0e28133..5be8ddf 100644 --- a/state/provider_circuit_breaker_state.json +++ b/state/provider_circuit_breaker_state.json @@ -10,5 +10,12 @@ "open_until": 0.0, "reason": null, "strikes": {} + }, + "ieee": { + "open_until": 1790933827.9323854, + "reason": "http_403", + "strikes": { + "http_403": 1 + } } } \ No newline at end of file