pacages/easyscan: trap EXIT and remove failed scans

This commit is contained in:
Primrose 2026-01-02 17:12:30 +01:00
parent 297c03ad79
commit 09e7d1adb8
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -11,6 +11,13 @@ tempdir="$(mktemp -d)"
filenames=() filenames=()
counter=1 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 while :; do
ok="true" ok="true"
echo "Scanning page $counter" echo "Scanning page $counter"
@ -51,6 +58,4 @@ pdfunite "${filenames[@]}" "$merged_filename"
mkdir -p "$(dirname "$OUTPUT_FILE")" mkdir -p "$(dirname "$OUTPUT_FILE")"
cp "$merged_filename" "$OUTPUT_FILE" cp "$merged_filename" "$OUTPUT_FILE"
# Make sure I don't remove things other than pdf clean
rm "$tempdir/"*.pdf
rm -d "$tempdir"