feat(F-055): completed feature
This commit is contained in:
@@ -210,24 +210,30 @@ build_prod() {
|
||||
|
||||
sync_uploads() {
|
||||
# Mirror admin's public/uploads to frontend and storefront so that product
|
||||
# images are reachable from any of the three apps.
|
||||
# images are reachable from any of the three apps. Also mirrors every
|
||||
# generated thumbnail subdir (40/, 200/, ...) so the static cached files
|
||||
# reach all three apps in lockstep.
|
||||
local src="$PROJECT_DIR/apps/admin/public/uploads"
|
||||
local peer1="$PROJECT_DIR/frontend/public/uploads"
|
||||
local peer2="$PROJECT_DIR/storefront/public/uploads"
|
||||
local peers=(
|
||||
"$PROJECT_DIR/frontend/public/uploads"
|
||||
"$PROJECT_DIR/storefront/public/uploads"
|
||||
)
|
||||
if [[ ! -d "$src" ]]; then
|
||||
return 0
|
||||
fi
|
||||
for peer in "$peer1" "$peer2"; do
|
||||
for peer in "${peers[@]}"; do
|
||||
mkdir -p "$peer"
|
||||
# copy every file present in source but missing in peer
|
||||
while IFS= read -r -d '' f; do
|
||||
local name
|
||||
name="$(basename "$f")"
|
||||
if [[ ! -f "$peer/$name" ]]; then
|
||||
cp "$f" "$peer/$name" 2>/dev/null || true
|
||||
find "$src" -maxdepth 2 -type f -print0 2>/dev/null | while IFS= read -r -d '' f; do
|
||||
local rel
|
||||
rel="${f#$src/}"
|
||||
if [[ ! -f "$peer/$rel" ]]; then
|
||||
mkdir -p "$(dirname "$peer/$rel")"
|
||||
cp "$f" "$peer/$rel" 2>/dev/null || true
|
||||
fi
|
||||
done < <(find "$src" -maxdepth 1 -type f -print0 2>/dev/null)
|
||||
done
|
||||
done
|
||||
# Ensure thumbnails are up to date for the current image set.
|
||||
"$PROJECT_DIR/scripts/generate-thumbnails.sh" --quiet
|
||||
}
|
||||
|
||||
spawn_service() {
|
||||
|
||||
Reference in New Issue
Block a user