Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Finder Handler Errors #172

Closed
L1cardo opened this issue Nov 29, 2024 · 19 comments
Closed

[BUG] Finder Handler Errors #172

L1cardo opened this issue Nov 29, 2024 · 19 comments

Comments

@L1cardo
Copy link
Contributor

L1cardo commented Nov 29, 2024

Describe the bug:

Pearcleaner won't uninstall app sometimes, it only appears sometimes, not everytime , so you may be not able to reproduce.

Steps to reproduce:

Try to uninstall app from finder extension

Info:

  • OS: [macOS 15.1.1]
  • Pearcleaner Version: [4.0.2]

Screenshots:

2024-11-29.10.29.37.2024-11-29.10.30.13.mov

Console Logs (For app crashes or hard to reproduce issues):

  1. Open the Terminal app and run the following command
log stream --level debug --style compact --predicate 'subsystem == "com.alienator88.Pearcleaner"'

image

@alienator88
Copy link
Owner

Hmm, yeah I haven't seen this issue before. I tried testing a few times with that same app you have in the video and I haven't been able to reproduce so far.
I'm curious if it's related to one of the files it attempts to delete. That AppleScript error is really weird..

@pantheraleo-7
Copy link

Speaking of uninstallation: I wanted to ask whether pearcleaner 'zaps' the homebrew installed cask or not?

@alienator88
Copy link
Owner

I think currently it only has uninstall --force set for the cask cleanup command.
I can add the --zap in there too just in case, but usually those folders are already caught by my app. Wouldn't hurt to add it though, good idea.

@pantheraleo-7
Copy link

usually those folders are already caught by my app

Not always I guess. I tried pearcleaner for the first time with raspberry-pi-imager (installed via homebrew) and it left ~/Library/Caches/Raspberry Pi.

@alienator88
Copy link
Owner

That's likely because the app name "Raspberry Pi Imager" and the folder is called "Raspberry Pi". Currently it only matches on app name and partial bundle identifiers.
Without changing the name search algorithm, it wouldn't catch that currently.
I did add fuzzy app name searching in the app list filtering, I might be able to use that to do fuzzy app name searches for the files as well.
I'll look into it.

@L1cardo
Copy link
Contributor Author

L1cardo commented Dec 3, 2024

That unicode translates into

NSAppleScriptErrorBriefMessage = "处理程序不能处理这个类的对象。";
NSAppleScriptErrorMessage = "“Finder”遇到一个错误:处理程序不能处理这个类的对象。";

Which is

NSAppleScriptErrorBriefMessage = "The handler cannot handle this type of object.";
NSAppleScriptErrorMessage = "Finder encountered an error: The handler cannot handle this type of object.";

@alienator88
Copy link
Owner

Right, which is why I was wondering if it's related to one of the files it was trying to delete.
You can hit CMD+E when looking at the files view to export a list of all the files into a text document.
Might help getting a list of those files.

The thing is there are a few things that can cause that handler error, file types, invalid paths, locked files, permissions, etc.
Unfortunately without being able to repro on my end, it's really a guess in the dark for me.
If you do repro again, export that list of file paths and maybe try deleting each file, one at a time and see which one causes the error. You could do it using Script Editor with something like:

set posixPath to "/path/to/your/file.txt"
tell application "Finder"
    delete (POSIX file posixPath)
end tell

@alienator88
Copy link
Owner

Something that I think could be a cause is maybe one of the files it finds in the Cache or Temp directories.
If they move or get deleted right before hitting Uninstall, it would actually crash the whole applescript for deleting all the files. I can probably add a check to make sure each file still exists right before running the script, if that was the issue here.

@L1cardo
Copy link
Contributor Author

L1cardo commented Dec 3, 2024

I can't reproduce either, it just happens sometimes, but I will pay more attention when it happens next time

@alienator88
Copy link
Owner

Sounds good!
Meanwhile, I'll add a validation function to the trash function to check each file path before passing it to the applescript.

@L1cardo
Copy link
Contributor Author

L1cardo commented Dec 4, 2024

Right, which is why I was wondering if it's related to one of the files it was trying to delete. You can hit CMD+E when looking at the files view to export a list of all the files into a text document. Might help getting a list of those files.

The thing is there are a few things that can cause that handler error, file types, invalid paths, locked files, permissions, etc. Unfortunately without being able to repro on my end, it's really a guess in the dark for me. If you do repro again, export that list of file paths and maybe try deleting each file, one at a time and see which one causes the error. You could do it using Script Editor with something like:

set posixPath to "/path/to/your/file.txt"
tell application "Finder"
    delete (POSIX file posixPath)
end tell

This AppleScript has problem, it says can't find POSIX
image

@alienator88
Copy link
Owner

Can probably simplify that apple script to this:

tell application "Finder"
	delete POSIX file "/Users/licardo/Downloads/1.txt"
end tell

@L1cardo
Copy link
Contributor Author

L1cardo commented Dec 6, 2024

There is this file, but the script can't delete it.
image

This is the whole file path

/Applications/Proxyman.app
/Library/LaunchDaemons/com.proxyman.NSProxy.HelperTool.plist
/Library/PrivilegedHelperTools/com.proxyman.NSProxy.HelperTool
~/.proxyman
~/.proxyman-data
~/Library/Application Support/com.proxyman.NSProxy
~/Library/Caches/Proxyman
~/Library/Caches/com.proxyman.NSProxy
~/Library/HTTPStorages/com.proxyman.NSProxy
~/Library/Preferences/com.proxyman.NSProxy.plist
~/Library/Preferences/com.proxyman.iconappmanager.userdefaults.plist
~/Library/Saved Application State/com.proxyman.NSProxy.savedState
~/Library/WebKit/com.proxyman.NSProxy
/var/folders/my/yxdm17rn3rx1xccnxlyj4_5m0000gn/C/com.proxyman.NSProxy
/var/folders/my/yxdm17rn3rx1xccnxlyj4_5m0000gn/T/com.proxyman.NSProxy

Above those files, the script failed to deletes files start with ~.

I tried rstarting the Pearcleaner and it can delete those files.

@alienator88
Copy link
Owner

What is that error, the same handler one from before? Sorry I can't read the language.

@L1cardo
Copy link
Contributor Author

L1cardo commented Dec 6, 2024

That unicode translates into

NSAppleScriptErrorBriefMessage = "处理程序不能处理这个类的对象。";
NSAppleScriptErrorMessage = "“Finder”遇到一个错误:处理程序不能处理这个类的对象。";

Which is

NSAppleScriptErrorBriefMessage = "The handler cannot handle this type of object.";
NSAppleScriptErrorMessage = "Finder encountered an error: The handler cannot handle this type of object.";

Yeah, the same error as this

@alienator88
Copy link
Owner

I've added a check to the deletion process to do 3 things:

  1. Make sure file still exists at the path before deleting
  2. Check if the file is locked and if it is, try to unlock. If it fails, skip the file
  3. Check that the file is writable, if it's not, skip it.

I'm hoping all these checks before actually running the uninstall command will prevent a lot of these handler issues.
Will have this out in the next release.

@alienator88 alienator88 changed the title [BUG] Won't uninstall app sometimes [BUG] Finder Handler Errors Dec 9, 2024
@alienator88
Copy link
Owner

Would you be able to check if you still see Finder handler issues with the latest build?
Side note, you can now push CMD+D to open a debug console and watch the logs stream in instead of having to use Terminal.
If you do still see issues, I unfortunately will have to put a pause on trying to fix this specific issue for the time being.

I'm looking to move away from using AppleScript/Finder for deleting the files so this shouldn't be an issue in the future.
I would like to move to using maybe a helper tool or some authorization services to execute sudo commands directly from Pearcleaner. Once that is done, this file handler problem shouldn't happen anymore.
For now, I'll close this issue, but feel free to reply on it as I'm curious if you still have the issue.

@L1cardo
Copy link
Contributor Author

L1cardo commented Dec 18, 2024

After some days of use, I haven't had that issue again.

Thanks for your working on this!

@alienator88
Copy link
Owner

That's good to hear and no problem at all!
It should get even more robust in the near future once I switch up how the file deletion is handled.
Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants