Merge pull request 'Fix Joplin sync by upgrading CLI and detecting sync errors' (#5) from feature/joplinupdate into main

Reviewed-on: #5
This commit was merged in pull request #5.
This commit is contained in:
2026-10-02 09:13:38 +00:00
3 changed files with 35 additions and 3 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Joplin Terminal (official npm package) # Joplin Terminal (official npm package)
RUN npm install --loglevel=error -g joplin RUN npm install --loglevel=error -g joplin@3.7.1
WORKDIR /app WORKDIR /app
COPY pyproject.toml requirements.txt ./ COPY pyproject.toml requirements.txt ./
+27 -2
View File
@@ -7,6 +7,31 @@ RESULT_JSON="/app/data/last_result.json"
log() { printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$*"; } log() { printf '%s %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$*"; }
fail() { log "ERROR: $*"; exit 1; } 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_URL:?JOPLIN_WEBDAV_URL is required}"
: "${JOPLIN_WEBDAV_USERNAME:?JOPLIN_WEBDAV_USERNAME 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. # 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..." log "Synchronising Joplin from WebDAV before writing..."
joplin --profile "$PROFILE" sync joplin_sync
if [[ "${JOPLIN_WRITE_ENABLED,,}" != "true" ]]; then if [[ "${JOPLIN_WRITE_ENABLED,,}" != "true" ]]; then
log "JOPLIN_WRITE_ENABLED=false: sync-only safety mode. No paper note will be written." 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 joplin --profile "$PROFILE" import "$TMP_MD" "$JOPLIN_NOTEBOOK" --format md -f
log "Synchronising Joplin changes to WebDAV..." log "Synchronising Joplin changes to WebDAV..."
joplin --profile "$PROFILE" sync joplin_sync
log "Completed: $REPORT_TITLE ($REPORT_COUNT papers)" log "Completed: $REPORT_TITLE ($REPORT_COUNT papers)"
@@ -10,5 +10,12 @@
"open_until": 0.0, "open_until": 0.0,
"reason": null, "reason": null,
"strikes": {} "strikes": {}
},
"ieee": {
"open_until": 1790933827.9323854,
"reason": "http_403",
"strikes": {
"http_403": 1
}
} }
} }