From a3e8e681a35199ff78d6a688c2c43f6bc76160e0 Mon Sep 17 00:00:00 2001 From: zart Date: Fri, 3 Jan 2025 14:14:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(smp=5Fcoder):=E6=8B=8D=E7=85=A7=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增检查临时文件夹中的图片文件是否存在 - 如果存在,则删除旧的图片文件 - 优化了脚本的可读性和健壮性 --- smp_coder/camera.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/smp_coder/camera.sh b/smp_coder/camera.sh index 09ffeab..df26a03 100644 --- a/smp_coder/camera.sh +++ b/smp_coder/camera.sh @@ -1,4 +1,16 @@ #!/usr/bin/bash +IMAGE_PATH="/tmp/image.jpg" + +if [ -f "$IMAGE_PATH" ]; then + echo "Image already exists at $IMAGE_PATH" + if sudo rm "$IMAGE_PATH"; then + echo "Successfully deleted $IMAGE_PATH" + else + echo "Failed to delete $IMAGE_PATH" + exit 1 + fi +fi + fswebcam -r 1280x720 --no-banner -S 20 /tmp/image.jpg \ No newline at end of file