Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a5b2b42d2 | ||
|
|
24a59c6e93 | ||
|
|
8c9afb65c3 |
@@ -54,10 +54,13 @@ git -C "$DIR" checkout -q -B main origin/main
|
|||||||
git -C "$DIR" reset -q --hard origin/main
|
git -C "$DIR" reset -q --hard origin/main
|
||||||
|
|
||||||
echo "[sync] scripts/portfolio-sync.mjs"
|
echo "[sync] scripts/portfolio-sync.mjs"
|
||||||
docker run --rm --memory 2g --cpus 2 --network bridge \
|
# portfolio-sync.mjs exits 1 when a single photo fails but still writes the others; those are committed below, and the
|
||||||
|
# run ends with exit 1 so systemd shows that something needs a look (journalctl -u portfolio-sync).
|
||||||
|
SYNC_RC=0
|
||||||
|
docker run --rm --memory 3g --cpus 2 --network bridge \
|
||||||
-e IMMICH_URL -e IMMICH_API_KEY -e PORTFOLIO_TAG_ID \
|
-e IMMICH_URL -e IMMICH_API_KEY -e PORTFOLIO_TAG_ID \
|
||||||
-v "$DIR":/app --mount type=tmpfs,destination=/app/.git -w /app "$NODE" \
|
-v "$DIR":/app --mount type=tmpfs,destination=/app/.git -w /app "$NODE" \
|
||||||
sh -c 'npm install --no-audit --no-fund --loglevel=error >/dev/null && node scripts/portfolio-sync.mjs'
|
sh -c 'npm install --no-audit --no-fund --loglevel=error >/dev/null && node scripts/portfolio-sync.mjs' || SYNC_RC=$?
|
||||||
|
|
||||||
if git -C "$DIR" status --porcelain -- src/assets/images/portfolio | grep -q .; then
|
if git -C "$DIR" status --porcelain -- src/assets/images/portfolio | grep -q .; then
|
||||||
git -C "$DIR" add -A src/assets/images/portfolio
|
git -C "$DIR" add -A src/assets/images/portfolio
|
||||||
@@ -69,3 +72,7 @@ if git -C "$DIR" status --porcelain -- src/assets/images/portfolio | grep -q .;
|
|||||||
else
|
else
|
||||||
echo "[sync] no changes"
|
echo "[sync] no changes"
|
||||||
fi
|
fi
|
||||||
|
if [ "$SYNC_RC" != 0 ]; then
|
||||||
|
echo "[sync] WARNING: portfolio-sync.mjs exited $SYNC_RC - some photos failed (see the lines with '!' above)"
|
||||||
|
exit "$SYNC_RC"
|
||||||
|
fi
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ function destName(asset) {
|
|||||||
async function downloadAndResize(asset, destPath) {
|
async function downloadAndResize(asset, destPath) {
|
||||||
const res = await api("GET", `/assets/${asset.id}/original`);
|
const res = await api("GET", `/assets/${asset.id}/original`);
|
||||||
const buf = Buffer.from(await res.arrayBuffer());
|
const buf = Buffer.from(await res.arrayBuffer());
|
||||||
await sharp(buf)
|
// Pixel shift and the 15000 px Instagram squares can exceed sharp's default limit (268 MP). JPEGs are shrunk while
|
||||||
|
// they are decoded, so memory stays low; the sync container still has a memory cap.
|
||||||
|
await sharp(buf, { limitInputPixels: 1_000_000_000 })
|
||||||
.rotate() // respektera EXIF-orientering
|
.rotate() // respektera EXIF-orientering
|
||||||
.resize(MAX_DIM, MAX_DIM, { fit: "inside", withoutEnlargement: true })
|
.resize(MAX_DIM, MAX_DIM, { fit: "inside", withoutEnlargement: true })
|
||||||
.withMetadata() // BEVARA EXIF (kritiskt för portfolions datum/kamera)
|
.withMetadata() // BEVARA EXIF (kritiskt för portfolions datum/kamera)
|
||||||
|
|||||||
Reference in New Issue
Block a user