checksum based cache for neocities uploads

This commit is contained in:
veclav talica 2024-02-10 22:15:32 +05:00
parent c1ccd1b465
commit 82b4976efb
2 changed files with 10 additions and 6 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ html/
**/.*/
**/*.jpg/
**/*.png/
**/*.upload-checksum

View File

@ -1,12 +1,15 @@
#!/usr/bin/bash
# todo: Create local cache containing file timestamps that were previously uploaded.
for cur in ./html/{*,*/*,*/*/*}; do
if [[ "$cur" == *"/tracks/"* ]]; then
continue
fi
if [ -f "$cur" ]; then
if [ -f "$cur" ] && [[ ! "$cur" == *.upload-checksum ]]; then
if [ -f "$cur.upload-checksum" ]; then
c=$(cat "$cur.upload-checksum" | sha256sum -c 2> /dev/null)
if [[ "$c" == *OK ]]; then
echo "$cur is up-to-date, skipping"
continue
fi
fi
echo $(sha256sum "$cur") > "$cur.upload-checksum"
d=$(dirname $(realpath --relative-to="./html" "$cur"))
if [[ "$d" == "." ]]; then
neocities upload $cur