fix: delete activity removes it from index.json; detail page uses lazy load
delete_activity now updates data_dir/index.json so merge_all no longer re-adds the summary for a deleted activity, preventing the broken "Activity not found" state after deletion. ActivityDetailLoader switches from loadIndex (all year shards) to loadIndexPaged (first year shard only) + direct file fallback, so opening an activity detail page no longer downloads the entire history.
This commit is contained in:
@@ -1288,6 +1288,17 @@ async def delete_activity(
|
||||
if images_dir.exists():
|
||||
shutil.rmtree(images_dir)
|
||||
|
||||
# Remove from the extract-level flat index so merge_all doesn't re-add
|
||||
# the summary even though the detail file is gone.
|
||||
index_path = dd / "index.json"
|
||||
if index_path.exists():
|
||||
try:
|
||||
idx = json.loads(index_path.read_text(encoding="utf-8"))
|
||||
idx["activities"] = [a for a in idx.get("activities", []) if a.get("id") != activity_id]
|
||||
index_path.write_text(json.dumps(idx, indent=2, ensure_ascii=False))
|
||||
except Exception:
|
||||
pass # corrupt index — merge_all will clean up on next run
|
||||
|
||||
# Remove from dedup cache so the file can be re-uploaded if needed
|
||||
cache_path = dd / ".bincio_cache.json"
|
||||
if cache_path.exists():
|
||||
|
||||
Reference in New Issue
Block a user