alienator88 / Pearcleaner

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

[BUG] Wrong size of .app in Finder and Pearcleaner #46

Closed theramzay closed 2 months ago

theramzay commented 2 months ago

Describe the bug

Wrong size of .app in Finder and in Pearcleaner

To Reproduce Steps to reproduce the behavior:

  1. Go to Apple App Store
  2. Find Remote Desktop Scanner
  3. Download
  4. Go to Applications folder in Fine and see size, then see size in Pearcleaner

Expected behavior

Same size of .app file in Pearcleaner and Finder

Desktop (please complete the following information):

Screenshots

image
alienator88 commented 2 months ago

Hey, thanks for that! I just looked at a few other apps on my end, and the size calculator seems to have trouble getting the exact size for the .app bundles. I'll work on this and see what I find.

alienator88 commented 2 months ago

Out of curiosity I checked the other AppCleaner and it also gets the smaller size 😆 image

alienator88 commented 2 months ago

So it turns out that there is no bug..there's 2 ways to get file sizes.

My app and the AppCleaner screenshot I just posted, use the .totalFileAllocatedSizeKey to get the size the app actually takes on disk. The AppCleaner screenshot you have, it looks like they decided to use the .fileSizeKey which does match Finder but is not accurate in terms of how much space it's actually taking on your drive. If you Get Info from Remote Desktop Scanner, you can see the size on disk is actually different than what Finder has, most likely. At least on my end it is. image

The .fileSizeKey gets the logical size of the file, but the .totalFileAllocatedSizeKey get the actual size, which could be different than the .fileSizeKey because modern operating systems use compression, deduplication and other features to lower the size a file actually takes on disk. Sometimes it can show bigger too, really depends on how many blocks it takes on the file system.

I personally think it makes more sense to get the actual size of disk space the app is using in this case. But it's a preference, I could just add a setting in the app where the user can choose to show the logical app size or the size on disk size.

alienator88 commented 2 months ago

Can also use this command to get the app size of the app from Terminal. This one should be different from Finder too: du -sk /PATH/TO/APP | cut -f1

theramzay commented 2 months ago

Interesting! I think toggle will be nice solution. And/or maybe toggle to (full)view like in Finder info menu, like '9,787,635 bytes(4,6 on disk)'

So settings option like:

'Show size: [Finder-like size | Real Size | Finder-like(Real Size)]' UPDATE: I mean segment picker

https://www.hackingwithswift.com/quick-start/swiftui/how-to-create-a-segmented-control-and-read-values-from-it

alienator88 commented 2 months ago

Sounds good, I'll add that to the roadmap. I'm currently trying to get something else working and I haven't been able to get it working how I want all day. Once I finish that, I'll look at adding the setting.

alienator88 commented 2 months ago

This has been added in v3.5.1