deploy_site and store_tree both extracted a commit's tree into .forge/store/<tree>/, each with its own copy of the archive, rename and touch. deploy_site now calls store_tree, so a site and a release share one way into the store: extracted once, into a temporary directory that a concurrent extraction of the same tree can't trip over, and touched when reused, so a gc running meanwhile spares it. site-preview checks the link points at the stored tree and that a deploy reusing an old tree makes it count as new.
- commit
- 278dd7e23ea3bca6062e33b208671a8d6f324b52
- parent
- d3d8e6e71b950198b28854ef7629a0196cfc86ff
- author
- cat <admin@dev.site>
- kind
- refactor risk score 1.5 of 3, Jev's estimate
| M | bin/ | 22 | ++++++++-------------- |
| M | test/ | 11 | +++++++++++ |
@@ -2084,7 +2084,7 @@ review_link() {
20842084 say "review #$1: $(review_url "$OWNER/$NAME" "$1")$on"20852085 }20862086 2087-# Extract a site tree into the content store and point its URL at it.2087+# Extract a site tree into the content store (store_tree) and point its URL at it.20882088 deploy_site() {20892089 link=$FORGE_WWW/$120902090 if [ "$2" = "$ZERO" ]; then@@ -2092,15 +2092,7 @@ deploy_site() {
20922092 [ -z "${FORGE_PAGES_DOMAIN:-}" ] || node "$FORGE_HOME/lib/hosts.ts" unregister "$1" || true20932093 return 020942094 fi2095- tree=$(git rev-parse "$2^{tree}")2096- store=$FORGE_STATE/store/$tree2097- if [ ! -d "$store" ]; then2098- mkdir -p "$store.tmp.$$"2099- git archive "$2" | tar -x -C "$store.tmp.$$"2100- mv "$store.tmp.$$" "$store"2101- fi2102- # A reused tree counts as new, so a concurrent forge gc leaves it alone.2103- touch -c "$store"2095+ store=$(store_tree "$2")21042096 mkdir -p "$(dirname "$link")"21052097 ln -sfn "$store" "$link"21062098 # Its own hostname, when the forge has a pages domain (lib/hosts.ts).@@ -2136,10 +2128,12 @@ push_site() {
21362128 fi21372129 }21382130 2139-# store_tree <commit>: extract its tree once into the content store, as2140-# deploy_site does, and print where. git archive stamps every file with the2141-# commit's time, so a tree extracted again (after a restore) gets the same2142-# mtimes. A reused tree counts as new, so a concurrent forge gc leaves it.2131+# store_tree <commit>: extract its tree once into the content store,2132+# .forge/store/<tree>/, and print where. Sites link to it (deploy_site),2133+# releases hard-link its files (release_link). git archive stamps every file2134+# with the commit's time, so a tree extracted again (after a restore) gets2135+# the same mtimes. A reused tree counts as new, so a concurrent forge gc,2136+# which spares what changed in its last --age minutes, leaves it alone.21432137 store_tree() {21442138 st_dir=$FORGE_STATE/store/$(git rev-parse "$1^{tree}")21452139 if [ ! -d "$st_dir" ]; then@@ -11,6 +11,17 @@ export FORGE_USER=dami
1111 mkdir -p "$T/site" && printf '<h1>docs v1</h1>\n' >"$T/site/index.html"1212 ok at "$T/w/d" "$FORGE" site push "$T/site" docs1313 has "$FORGE_WWW/sites/dami/greet/docs/index.html" 'docs v1'14+# Its tree is extracted once into the store, which the link points at. A15+# deploy that reuses a stored tree touches it, so a gc running meanwhile16+# (which spares what changed in its last 10 minutes) leaves it be.17+g=$FORGE_ROOT/dami/greet.git18+store=$FORGE_ROOT/.forge/store/$(git --git-dir="$g" rev-parse 'refs/sites/docs^{tree}')19+eq "$(readlink "$FORGE_WWW/sites/dami/greet/docs")" "$store"20+touch -t 202001010000 "$store"21+ok at "$T/w/d" git fetch -q origin refs/sites/docs22+ok push_as dami "$T/w/d" origin FETCH_HEAD:refs/sites/redo23+eq "$(readlink "$FORGE_WWW/sites/dami/greet/redo")" "$store"24+eq "$(find "$store" -maxdepth 0 -mmin -10)" "$store"1425 1526 clone ana dami/greet "$T/w/a"1627 at "$T/w/a" git switch -q -c ana/tweak