From 09e7d1adb80f9a7f0105553a95b4b4f19b33c450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Fri, 2 Jan 2026 17:12:30 +0100 Subject: [PATCH] pacages/easyscan: trap EXIT and remove failed scans --- nix/packages/by-name/easyscan/easyscan.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nix/packages/by-name/easyscan/easyscan.sh b/nix/packages/by-name/easyscan/easyscan.sh index c9d54dc1..633c7686 100644 --- a/nix/packages/by-name/easyscan/easyscan.sh +++ b/nix/packages/by-name/easyscan/easyscan.sh @@ -11,6 +11,13 @@ tempdir="$(mktemp -d)" filenames=() counter=1 +function clean() { + # Make sure I don't remove things other than pdf + rm "$tempdir/"*.pdf + rm -d "$tempdir" +} +trap clean EXIT + while :; do ok="true" echo "Scanning page $counter" @@ -51,6 +58,4 @@ pdfunite "${filenames[@]}" "$merged_filename" mkdir -p "$(dirname "$OUTPUT_FILE")" cp "$merged_filename" "$OUTPUT_FILE" -# Make sure I don't remove things other than pdf -rm "$tempdir/"*.pdf -rm -d "$tempdir" +clean