]> Sergey Matveev's repositories - nnn.git/commitdiff
use trap to delete the temp files
authorjohnnybash <georgpfahler@wachenzell.org>
Sun, 27 Dec 2020 18:27:11 +0000 (19:27 +0100)
committerjohnnybash <georgpfahler@wachenzell.org>
Sun, 27 Dec 2020 18:27:11 +0000 (19:27 +0100)
plugins/preview-tui

index 6358b4fa4511daf6153441f0a2c17a7245c13de6..a24ac413a0024c7ec60b7544b0062f6dcf69a815 100755 (executable)
@@ -158,10 +158,11 @@ preview_file () {
     elif [ "$encoding" = "binary" ]; then
         if [ "${mimetype%%/*}" = "image" ] || [ "${mimetype%%/*}" = "video" ]; then
             if [ "${mimetype%%/*}" = "video" ] && [ "$USE_VIDEOTHUMB" -ne 0 ] && exists ffmpegthumbnailer; then
-               videothumb="/tmp/videothumb.$$.png"
-               ffmpegthumbnailer -s 0 -i "$1" -o "$videothumb"
-               set "$videothumb"
-           fi
+                videothumb="/tmp/videothumb.$$.png"
+                ffmpegthumbnailer -s 512 -i "$1" -o "$videothumb" >/dev/null 2>&1
+                set "$videothumb"
+                trap 'rm "$videothumb"' EXIT
+            fi
             if [ "$TERMINAL" = "kitty" ]; then
                 # Kitty terminal users can use the native image preview method.
                 kitty +kitten icat --silent --transfer-mode=stream --stdin=no \
@@ -214,7 +215,6 @@ if [ "$PREVIEW_MODE" ] ; then
         kitty @ last-used-layout --no-response >/dev/null 2>&1
     fi
 
-    rm $videothumb
     exit 0
 fi