From 8754669d4027c1f5e8892a2188c296c45fc87221 Mon Sep 17 00:00:00 2001 From: yuanzhen869 Date: Fri, 24 Apr 2026 10:57:35 +0800 Subject: [PATCH] Preserve synced workspace data on startup --- tools/init_runtime_data.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/init_runtime_data.sh b/tools/init_runtime_data.sh index 1e124b4..cb15a80 100644 --- a/tools/init_runtime_data.sh +++ b/tools/init_runtime_data.sh @@ -57,6 +57,10 @@ refresh_workspace_builtin_entries() { fi } +workspace_has_sync_metadata() { + [ -f "$DATA_ROOT/state/sync_status.json" ] +} + migrate_legacy_manual_catalog() { legacy_dir="$DATA_ROOT/workspace/brands/local" target_dir="$DATA_ROOT/workspace/local" @@ -98,7 +102,14 @@ init_path() { fi if [ "$rel_path" = "workspace" ] && [ -d "$src_path" ] && [ ! -L "$src_path" ]; then - refresh_workspace_builtin_entries "$src_path" "$dst_path" + if [ ! -e "$dst_path" ] && [ ! -L "$dst_path" ]; then + mkdir -p "$(dirname "$dst_path")" + cp -a "$src_path" "$dst_path" + elif workspace_has_sync_metadata; then + sync_missing_dir_entries "$src_path/local" "$dst_path/local" + else + refresh_workspace_builtin_entries "$src_path" "$dst_path" + fi elif [ -d "$src_path" ]; then if [ ! -e "$dst_path" ] && [ ! -L "$dst_path" ]; then mkdir -p "$(dirname "$dst_path")"