diff --git a/.gitignore b/.gitignore index b47985c..bec3509 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ html/ **/.*/ **/*.jpg/ **/*.png/ +**/*.upload-checksum diff --git a/upload.sh b/upload.sh index e6cd5db..e1ae128 100755 --- a/upload.sh +++ b/upload.sh @@ -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