From bb479c937112923044deffe595c1149244dde3f4 Mon Sep 17 00:00:00 2001 From: veclav talica Date: Sat, 10 Feb 2024 22:27:52 +0500 Subject: [PATCH] neocities-cache article --- articles/neocities-cache/page.mmd | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 articles/neocities-cache/page.mmd diff --git a/articles/neocities-cache/page.mmd b/articles/neocities-cache/page.mmd new file mode 100644 index 0000000..4d9aebd --- /dev/null +++ b/articles/neocities-cache/page.mmd @@ -0,0 +1,31 @@ +Title: Cached Neocities Uploads +Brief: Making uploading of directories to Neocities less painful. +Date: 1707585916 +Tags: Bash +CSS: /style.css + +Quick and dirty Bash-based sha256sum checksum solution to create stamps for later checking and rejection. + +```bash +#!/usr/bin/bash + +for cur in ./html/{*,*/*,*/*/*}; do + 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 + else + neocities upload -d $(dirname $(realpath --relative-to="./html" "$cur")) $cur + fi + fi +done + +```