add a check for saving the wrong thing
- ID
2d12a30- date
2022-09-17 17:56:23+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
57ea1e9- message
add a check for saving the wrong thing- changed files
1 file, 14 additions
Changed files
ds (684) → ds (1123)
diff --git a/ds b/ds
index a9db805..464754c 100755
--- a/ds
+++ b/ds
@@ -18,6 +18,20 @@
set -o errexit
set -o nounset
+LATEST_DOWNLOAD="$(latest_download)"
+MTIME=$(ls -l "$LATEST_DOWNLOAD" | awk '{print $5}')
+NOW=$(date +%s)
+
+# Do a sense check: is this a file I downloaded recently?
+#
+# If not, I may be running `ds` before I've downloaded the file, which
+# might mean I save the wrong thing -- warn against this.
+if (( NOW - MTIME > 1000 ))
+then
+ echo "Latest download '$LATEST_DOWNLOAD' seems quite old, are you sure this is what you want?"
+ exit 1
+fi
+
docstore add \
"$(latest_download)" \
--source_url=$(~/.cargo/bin/safari url) \