fix: prune dist/data before rsync in _trigger_rebuild and manual rebuild endpoint
Same fix as cea1dbc (post-receive hook) but missed in server.py: Astro resolves
the public/data symlink and copies all activity JSON into dist/; without pruning,
every Strava sync / upload / edit that triggers a full build + rsync duplicates
GBs of data into the nginx webroot.
Both rsync callsites now rm -rf dist/data + pass --exclude=data/ to rsync.
This commit is contained in:
+13
-2
@@ -375,8 +375,15 @@ def _trigger_rebuild(handle: str) -> None:
|
|||||||
_handle, result.returncode, result.stdout, result.stderr)
|
_handle, result.returncode, result.stdout, result.stderr)
|
||||||
else:
|
else:
|
||||||
log.info("rebuild[%s]: build done, rsyncing", _handle)
|
log.info("rebuild[%s]: build done, rsyncing", _handle)
|
||||||
|
# Prune dist/data/ before rsync: Astro resolves the
|
||||||
|
# public/data symlink and copies all activity JSON into
|
||||||
|
# dist/, but nginx already serves /data/ directly from
|
||||||
|
# the live data dir — rsyncing it would duplicate GBs.
|
||||||
|
dist_data = Path(_site_dir) / "dist" / "data"
|
||||||
|
if dist_data.exists():
|
||||||
|
shutil.rmtree(dist_data)
|
||||||
rsync = subprocess.run(
|
rsync = subprocess.run(
|
||||||
["rsync", "-a", "--delete",
|
["rsync", "-a", "--delete", "--exclude=data/",
|
||||||
f"{_site_dir}/dist/", _webroot + "/"],
|
f"{_site_dir}/dist/", _webroot + "/"],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
@@ -707,8 +714,12 @@ async def admin_rebuild_sync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if result.returncode == 0 and webroot:
|
if result.returncode == 0 and webroot:
|
||||||
|
dist_data = site_dir / "dist" / "data"
|
||||||
|
if dist_data.exists():
|
||||||
|
shutil.rmtree(dist_data)
|
||||||
rsync = subprocess.run(
|
rsync = subprocess.run(
|
||||||
["rsync", "-a", "--delete", f"{site_dir}/dist/", str(webroot) + "/"],
|
["rsync", "-a", "--delete", "--exclude=data/",
|
||||||
|
f"{site_dir}/dist/", str(webroot) + "/"],
|
||||||
capture_output=True, text=True, timeout=120,
|
capture_output=True, text=True, timeout=120,
|
||||||
)
|
)
|
||||||
resp["rsync_returncode"] = rsync.returncode
|
resp["rsync_returncode"] = rsync.returncode
|
||||||
|
|||||||
Reference in New Issue
Block a user