alienator88 / Pearcleaner

A free, source-available and fair-code licensed mac app cleaner
https://itsalin.com/appInfo/?id=pearcleaner
Other
2.66k stars 60 forks source link

[FR] Find and (optionally) Remove Orphaned Files #90

Closed fpuhan closed 1 month ago

fpuhan commented 1 month ago

Is your feature request related to a problem? Please describe.

I've been trying to locate where Apple now stores some information under Sonoma (14.6) and much to my surprise have found leftover files from applications that have not existed on my Mac in years! For example Live365, a streaming audio service, no longer exists on my Mac, and hasn't for quite some time. Yet, I found remnants of it in .plist files and user and System libraries. No app I've used, including MacCleaner have found and offered to remove them.

Describe the solution you'd like

I suspect app removers like Pearcleaner work by identifying the app and then locating associated preference and plist files, license keys, etc. Perhaps a reverse search on libraries for unlinked or removed apps might do the trick? I confess, this would likely be a lengthy process, and one that need not be run often, but it could clear up a lot of cruft.

Describe alternatives you've considered

MacCleaner and CCleaner (free and commercial) both attempt to do this, but since I've found files still on my disk, they don't seem to work 100% of the time.

I can write a simple shell script to traverse my ~/Library folder and iteratively ask me if I wish to remove files, but that's tedious and prone to error (missing files, deleting the wrong files, etc.). For example, find . -name "*.log" -exec /bin/rm -i {} \;

Additional context Screenshot 2024-08-05 at 11 13 49 AM Screenshot 2024-08-05 at 11 19 39 AM

alienator88 commented 1 month ago

Does the Leftover File search I already have in the app not find these for you? It's set to look in that Preferences folder already, plus more: https://github.com/alienator88/Pearcleaner/blob/91f4ddd1a4447727221f3e88077929ed21e50020/Pearcleaner/Logic/Locations.swift#L90

As a test I added a dummy file with the same name for that plist and it found it, when I filter the results down.

Launch from the menu button: image

fpuhan commented 1 month ago

Wow, color me embarrassed! I’ve focused on the settings to the exclusion of other items on the menu! 🫢

A scan just revealed 33.39 GB of “leftover” files. I’ll have to investigate before I delete them, but this is very cool. Looks like the fastest turnaround on a feature request I’ve ever seen!

Thanks!

Fred

On Aug 5, 2024, at 11:35 AM, Alin Lupascu @.***> wrote:

Does the Leftover File search I already have in the app not find these for you? It's set to look in that Preferences folder already, plus more: https://github.com/alienator88/Pearcleaner/blob/91f4ddd1a4447727221f3e88077929ed21e50020/Pearcleaner/Logic/Locations.swift#L90

As a test I added a dummy file with the same name for that plist and it found it, when I filter the results down.

Launch from the menu button: image.png (view on web) https://github.com/user-attachments/assets/4d693f3a-f032-4075-9789-2ac3b9167a20 — Reply to this email directly, view it on GitHub https://github.com/alienator88/Pearcleaner/issues/90#issuecomment-2269360880, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXVB5AYAYLM4BM5IS5DSFLLZP6LUBAVCNFSM6AAAAABMAQX7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRZGM3DAOBYGA. You are receiving this because you authored the thread.

alienator88 commented 1 month ago

haha no worries! I know it's a little hidden in that menu. I'm working on making some UI changes to expose it as a main button in the UI later on. Currently it's only really mentioned in the Tips tab in the Settings of the app.

fpuhan commented 1 month ago

Geez, I’m amazed. I have stuff dating back to 2008. This machine wasn’t even built until 2020!

What happens when you migrate, then update, then migrate, then update… Whew.

On Aug 5, 2024, at 11:58 AM, Alin Lupascu @.***> wrote:

haha no worries! I know it's a little hidden in that menu. I'm working on making some UI changes to expose it as a main button in the UI later on. Currently it's only really mentioned in the Tips tab in the Settings of the app.

— Reply to this email directly, view it on GitHub https://github.com/alienator88/Pearcleaner/issues/90#issuecomment-2269406592, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXVB5A43XVKXXHCKVTBTPZ3ZP6OJFAVCNFSM6AAAAABMAQX7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRZGQYDMNJZGI. You are receiving this because you authored the thread.

alienator88 commented 1 month ago

Yeah, you're bound to have a ton of legacy stuff on there 😂

fpuhan commented 1 month ago

In these days of terabyte-size disks, 33.39 GB isn’t much. But it’s useless, so I might as well get rid of it. Thank you!

On Aug 5, 2024, at 12:23 PM, Alin Lupascu @.***> wrote:

Yeah, you're bound to have a ton of legacy stuff on there 😂

— Reply to this email directly, view it on GitHub https://github.com/alienator88/Pearcleaner/issues/90#issuecomment-2269452153, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXVB5A4GEC5NLYXA75RMNRLZP6RGTAVCNFSM6AAAAABMAQX7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRZGQ2TEMJVGM. You are receiving this because you authored the thread.

fpuhan commented 1 month ago

Can I ask you a question not Pearcleaner related, but as someone who obviously knows his way around a Mac, do you know under Sonoma where Mac stores the desktop image file names?

I use five spaces, each with photos from user-added folders (I take a lot of photographs). They are set to randomly change once an hour. I put together a little process under Ventura that worked when I called it.

The photo image names under Ventura were kept in a sqlite database at ~/Library/Application Support/Dock/desktoppicture.db. I would simply run a query, tail the result for the last five entries from the ‘data’ table and then pipe that to a nifty little program called Plash that would render the names as an overlay. This is now broken under Sonoma, and even trying to find files in /Library or ~/Library by name or change time hasn’t revealed them. There is a .plist that points to the folder, but not to the actual file name. Does this sound familiar to you?

Thanks for your consideration. If you don’t want to be bothered, no worries, and no offense taken.

Best,

Fred

On Aug 5, 2024, at 12:27 PM, Frederic Puhan @.***> wrote:

In these days of terabyte-size disks, 33.39 GB isn’t much. But it’s useless, so I might as well get rid of it. Thank you!

On Aug 5, 2024, at 12:23 PM, Alin Lupascu @.***> wrote:

Yeah, you're bound to have a ton of legacy stuff on there 😂

— Reply to this email directly, view it on GitHub https://github.com/alienator88/Pearcleaner/issues/90#issuecomment-2269452153, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXVB5A4GEC5NLYXA75RMNRLZP6RGTAVCNFSM6AAAAABMAQX7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRZGQ2TEMJVGM. You are receiving this because you authored the thread.

alienator88 commented 1 month ago

Well I can't be too sure since I've never dealt with those files myself, but testing it on my computer real quick, I'm seeing the image file names in the data table. It seems to have all the data in one table column called value though, so it's not separated in unique columns to where you can grab just the image file path:

> Dock sqlite3 desktoppicture.db
SQLite version 3.43.2 2023-10-10 13:08:14
Enter ".help" for usage hints.
sqlite> select * from data;
Black.png
1
0.0121805109083652
0.556764602661133
2
3
~/Pictures/MBP Wallpapers
3600.0
MBP14_M1Pro+2.png
~/Pictures/mojave.png
MBP14_MaxMatte.png
~/Pictures
sqlite>
fpuhan commented 1 month ago

Yes, that’s what worked for me under macOS 13.x (Ventura). But now under 14.6 (Sonoma) it’s a zero-byte file. I thought perhaps there was some corruption after I upgraded (?) to Sonoma, so I moved the file out to my Desktop and restarted my Mac. The file was automatically created, but it’s stayed a zero-byte file since. My desktop spaces are still being randomly updated, but I can’t find where macOS is storing the data.

Fred

On Aug 5, 2024, at 12:55 PM, Alin Lupascu @.***> wrote:

Well I can't be too sure since I've never dealt with those files myself, but testing it on my computer real quick, I'm seeing the image file names in the data table. It seems to have all the data in one table column called value though, so it's not separated in unique columns to where you can grab just the image file path:

Dock sqlite3 desktoppicture.db SQLite version 3.43.2 2023-10-10 13:08:14 Enter ".help" for usage hints. sqlite> select * from data; Black.png 1 0.0121805109083652 0.556764602661133 2 3 ~/Pictures/MBP Wallpapers 3600.0 MBP14_M1Pro+2.png ~/Pictures/mojave.png MBP14_MaxMatte.png ~/Pictures sqlite> — Reply to this email directly, view it on GitHub https://github.com/alienator88/Pearcleaner/issues/90#issuecomment-2269508185, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXVB5AZL7LGCZ7QSMLHXHVLZP6VBVAVCNFSM6AAAAABMAQX7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRZGUYDQMJYGU. You are receiving this because you authored the thread.

alienator88 commented 1 month ago

Hmm, I see, you're probably right. I tried changing desktop wallpaper and the db file doesn't update. Wiped it and still nothing new in there. Found that it is actually stored here now: ~/Library/Application Support/com.apple.wallpaper/Store/Index.plist This fork of pywal has a catch for the Sonoma changes here, you can explore this and see if you can make your workflow work with this: https://github.com/robwaz/pywal/blob/dbfd6206be60f6030c5630ad8287deb6e60a8bb1/pywal/wallpaper.py#L177-L227

fpuhan commented 1 month ago

Thank you for your time and effort. I am truly appreciative.

Previously, I used Apple’s plutil command to view this plist, as it’s listed as a binary format. Plutil allows for the viewing and converting into XML, JSON, binary, swift and Objective C. The Index.plist file you mention won’t convert to JSON, but I output to an XML file and saw paths to the images, but not the image names. There is a bunch of what I gather to be binary-encoded data still in the file, so if that’s Apple making a human-unreadable pointer to a file, I fear there’s nothing one can do.

I sent a note to the developer of TopNotch, a utility that “masks” the stupid “notch” that Apple has imposed on the M2 MacBook Pro because the program takes the original image and then processes it to another with the notch “removed.” I figured that they should know where the image names are stored, but as yet I’ve heard no reply. You’ve been very kind with your time, and I’m sorry to have caused you to waste it. I’m not a developer (any more - many years ago I wrote code, but today’s programming is not in my wheelhouse any more), but simply a casual hacker trying to find an answer to a personal problem that I once had a solution for.

(FYI: TopNotch also uses ~/Library/Application Support for its TopNotch folder, that contains two folders: ‘originals' and ‘processed.’ I’m just trying to learn where and how they derive the ‘originals.”)

Fred

On Aug 5, 2024, at 3:02 PM, Alin Lupascu @.***> wrote:

Hmm, I see, you're probably right. I tried changing desktop wallpaper and the db file doesn't update. Wiped it and still nothing new in there. Found that it is actually stored here now: ~/Library/Application Support/com.apple.wallpaper/Store/Index.plist This fork of pywal has a catch for the Sonoma changes here, you can explore this and see if you can make your workflow work with this: https://github.com/robwaz/pywal/blob/dbfd6206be60f6030c5630ad8287deb6e60a8bb1/pywal/wallpaper.py#L177-L227

— Reply to this email directly, view it on GitHub https://github.com/alienator88/Pearcleaner/issues/90#issuecomment-2269718370, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXVB5AZ6WZBS7IYO6PKSAMTZP7D3ZAVCNFSM6AAAAABMAQX7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRZG4YTQMZXGA. You are receiving this because you authored the thread.

alienator88 commented 1 month ago

So I opened the plist with Xcode and it shows me the file name as well. Unless I'm looking at the wrong thing 😂 image

fpuhan commented 1 month ago

This is too weird. I also opened the file in Xcode and it just shows me the same thing I got with plutil. A folder path but no file name.

On Aug 5, 2024, at 7:36 PM, Alin Lupascu @.***> wrote:

So I opened the plist with Xcode and it shows me the file name as well. Unless I'm looking at the wrong thing 😂 image.png (view on web) https://github.com/user-attachments/assets/fcc6e084-1f24-4f8a-9f8e-62113b8d71bd — Reply to this email directly, view it on GitHub https://github.com/alienator88/Pearcleaner/issues/90#issuecomment-2270096791, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXVB5AZQ3HMMGXX2WGX6BDTZQAD7HAVCNFSM6AAAAABMAQX7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZQGA4TMNZZGE. You are receiving this because you authored the thread.

fpuhan commented 1 month ago

Hi Alin,

One more comment and then I won’t bother you anymore. I have two MacBook I’m using, a 2020 M1 MacBook Pro and a 2022 M2 MacBook Air (both the 13” models). The M2 is the one with the irritating “notch” Apple chose to impose on us, and which I have added the nice freeware TopNotch to remove it. The M1 was running Ventura until I updated recently. The M2 has been running Sonoma. My hack was running on the M1, and which Ventura broke.

When I started digging into this, I found the TopNotch program took the original desktop images and made copies of them with the notch removed. The original and processed images are stored in TopNotch’s location in ~/Library/Application Support. Having been unable to discern why the M1 doesn’t seem to know the actual file names of the desktop images, I began poking around on the M2, which isn’t running my hack, and has never run it. Checking the Index.plist on the M2 shows actual file names. These file names all point to TopNotch’s “processed” files. The names given are not my original names, but appear to be code-generated names. Well, that makes sense, but it begs the question, why does my M1 not show the names? I’m not running TopNotch on it.

But that leaves what I think is the only other possibility: Some other utility (menu bar, daemon) is also re-writing image names. And this is colliding with Apple’s default storing and naming process. Ah, what problems we impose when we start adding our own features and add-ons, eh? This is the great benefit of Pearcleaner - it helps us get rid of old, useless stuff! :)

Finally, I’m not sure Apple isn’t also culpable in this confusion. On my M2, I added another space and set its desktop image like the others, just to see what might happen in the background. This makes a total of five spaces on it, yet when I query the ~/Library/Application Support/com.apple.wallpaper/Store/Index.plist in terminal with plutil -p Index.plist | grep relative I get 64 items! Some of those items I see don’t even exist on the file system any more. Maybe Apple feels it’s necessary to keep an archive of items, but I suspect they just add entries to the plist without doing any housecleaning. Still, I deleted the plist, killed the Dock (to clear any cache) and the plist was created anew. Still with the 64 entries! So, Apple is storing a history. Where I don’t know, and after all this, I’m going to give up on my hack.

Besides, Sequoia (macOS 15) is going to hit release status soon, and that will likely change the way Apple does things once again. Sigh.

Again, thank you for taking the time to respond to my inane queries. I’d like to thank you, so I’ve made a sponsorship donation on your GitHub site. Enjoy a cup on me!

Best regards,

Fred

On Aug 5, 2024, at 9:05 PM, Frederic Puhan @.***> wrote:

This is too weird. I also opened the file in Xcode and it just shows me the same thing I got with plutil. A folder path but no file name.

<Screenshot 2024-08-05 at 9.01.39 PM.jpeg>

On Aug 5, 2024, at 7:36 PM, Alin Lupascu @.***> wrote:

So I opened the plist with Xcode and it shows me the file name as well. Unless I'm looking at the wrong thing 😂 image.png (view on web) https://github.com/user-attachments/assets/fcc6e084-1f24-4f8a-9f8e-62113b8d71bd — Reply to this email directly, view it on GitHub https://github.com/alienator88/Pearcleaner/issues/90#issuecomment-2270096791, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXVB5AZQ3HMMGXX2WGX6BDTZQAD7HAVCNFSM6AAAAABMAQX7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZQGA4TMNZZGE. You are receiving this because you authored the thread.

alienator88 commented 1 month ago

Well shoot, that just leaves everything even more confusing, huh? I'm out of ideas on this one.. Also, thank you so much for the sponsor donation Fred, it's very much appreciated!

fpuhan commented 1 month ago

Yeah, and Apple’s tech support is silent on this (and many other topics - a far cry from how they were when the Mac was introduced (yeah, I’m that old. I used to have the original three-volume Inside Macintosh developer guides where Apple opened the kimono entirely). I’ve long since stopped being a developer of any kind, although I still have a developer account. Hmm.

On Aug 6, 2024, at 11:44 AM, Alin Lupascu @.***> wrote:

Well shoot, that just leaves everything even more confusing, huh? I'm out of ideas on this one.. Also, thank you so much for the sponsor donation Fred, it's very much appreciated!

— Reply to this email directly, view it on GitHub https://github.com/alienator88/Pearcleaner/issues/90#issuecomment-2271602343, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXVB5A53DTQSJJI36333OX3ZQDVMLAVCNFSM6AAAAABMAQX7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZRGYYDEMZUGM. You are receiving this because you authored the thread.