-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Problem
After the workspace sync fix in #102, workspace and skills are still not restored on container startup in some cases.
should_restore_from_r2() compares timestamps between $BACKUP_DIR/.last-sync (R2) and $CONFIG_DIR/.last-sync (local). The function is called separately for each restore block — config, workspace, and skills.
The config restore runs first and copies .last-sync into $CONFIG_DIR:
cp -f "$BACKUP_DIR/.last-sync" "$CONFIG_DIR/.last-sync" 2>/dev/null || trueAfter this, subsequent calls to should_restore_from_r2() for workspace and skills see matching timestamps and return false, silently skipping the restore.
Affected code
start-openclaw.sh lines 58-121 — each restore block independently calls should_restore_from_r2.
Fix
Evaluate the function once before any restore operations:
DO_RESTORE=false
if should_restore_from_r2; then
DO_RESTORE=true
fiThen use [ "$DO_RESTORE" = true ] in each restore block instead of calling the function again.
Testing
Deployed and verified on a live Cloudflare Workers container. After fix, workspace files (IDENTITY.md, MEMORY.md, memory/) and skills are correctly restored from R2 on startup.
Co-authored with Claude Code (Opus 4.6).