alanhe421 / alfred-workflows

Save time, Improve life.🚀 ☕️ 💻
https://alfred.1991421.cn
MIT License
659 stars 63 forks source link

[Bug]: QR Reader workflow doesn't delete old screenshot (Solution included) #393

Closed stavfx closed 1 year ago

stavfx commented 1 year ago

Describe the bug

The first AppleScript in the flow has this block:

tell application "Finder"
    if exists savePath then
        delete savePath
    end if
end tell

For some reason on my machine, if exists savePath on my machine always returns false. I solved this by changing the above block to

set the screenshotFile to savePath as POSIX file
tell application "Finder"
    if exists screenshotFile then
        delete screenshotFile
    end if
end tell

I didn't know what's the right way to fix this officially, so I didn't make a PR, just this issue.

Workflow Name

QR Reader

Alfred Version

5.1.3 [2175]

MacOS Version

macOS 13 Ventura

Mac Chip

Apple Silicon (like M1, M2)

MacOS Locale

EN


Workflow Homepage is 👉 QR Reader

alanhe421 commented 1 year ago

@stavfx

I haven't been able to reproduce it, but I think the writing here can be improved. We can solve it directly using a shell command to avoid the situation you mentioned. You can give it a try.

I test ok.

do shell script "rm -f " & quoted form of savePath

image

If it's okay, I'll release a new version.

stavfx commented 1 year ago

Yup, that works even better. since it doesn't trigger the trash sound effect. Thanks! 🎉

alanhe421 commented 1 year ago

https://github.com/alanhg/alfred-workflows/tree/master/qr-reader

The new version released.