You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
657 B
22 lines
657 B
#!/usr/bin/env bash |
|
set -euo pipefail |
|
|
|
# Find uploads past expiry (status=active AND now > expires_at), unpin & mark expired |
|
mapfile -t CIDS < <(sudo -u postgres psql ipfsapp -Atc \ |
|
"SELECT cid FROM uploads WHERE status='active' AND now() > expires_at") |
|
|
|
if ((${#CIDS[@]}==0)); then |
|
echo "$(date -Is) nothing to do" |
|
exit 0 |
|
fi |
|
|
|
for cid in "${CIDS[@]}"; do |
|
echo "$(date -Is) expiring $cid" |
|
ipfs pin rm "$cid" || true |
|
sudo -u postgres psql ipfsapp -c \ |
|
"UPDATE uploads SET status='expired' WHERE cid='${cid}'" >/dev/null |
|
done |
|
|
|
# light gc to free space (safe if nothing is fetched right now) |
|
ipfs repo gc --quiet || true |
|
echo "$(date -Is) done"
|
|
|