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/ **/*.jpg/
**/*.png/ **/*.png/
**/*.upload-checksum

View File

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