d4rken-org / sdmaid-se

SD Maid 2/SE is Android's most thorough cleaning tool.
https://play.google.com/store/apps/details?id=eu.darken.sdmse
GNU General Public License v3.0
2.77k stars 432 forks source link

Can't find Empty Folders inside SD Card #1381

Closed SirNiklaas closed 2 months ago

SirNiklaas commented 2 months ago

Describe the bug SD Maid SE does not find any empty folders inside the expandable storage.

To Reproduce Steps to reproduce the behavior:

  1. Open your expandable storage inside any file manager
  2. There go into any folder with any type of content
  3. Delete everything including hidden files so it will be completely empty
  4. Open SD Maid SE application and run System Cleaner with the "Empty Folder" setting enabled

Expected behavior I expected it to behave the same as with the internal storage. Searching for any empty folder and if it finds any I can delete them just with one button/click

Smartphone:

Screenshots/Video Here's a short video I made. The file explorer is in German but it should be still understandable. Also not to be confused I showed the settings while the app ran through my storage because it usually takes up to 25 sec. https://imgur.com/a/5q3V2Zb

d4rken commented 2 months ago

You are right, that does look like it should work. Can you record a debug log of the scan?

https://github.com/d4rken-org/sdmaid-se/wiki/Bugs#debug-log

The only idea I currently have that it somehow falls under the default exclusions or user created exclusions.

The filter is defined here: https://github.com/d4rken-org/sdmaid-se/blob/main/app/src/main/java/eu/darken/sdmse/systemcleaner/core/filter/stock/EmptyDirectoryFilter.kt

SirNiklaas commented 2 months ago

I've recorded a debug log. Hopefully I did it right. I tested it this time with an empty folder called "Example Folder" in each the internal and expandable storage. The internal folder was found while again the expandable one wasn't.

eu.darken.sdmse_logfile_1725361756503.zip

About the filter I also have screenshots attached showing the in-app settings where it's visible that only the two default apps are excluded. There's no path added to it. And about your link where with the defined filter, I'm unfortunately not a programmer in any way but if I read it right they shouldn't affect it, because the lines 52-69 only affect the default created folders? . Though there's something mentioning SDCARD in the 44th line, but I'm not really sure what that line does.

Screenshot_20240903_131302_SD Maid SE Screenshot_20240903_131403_SD Maid SE

d4rken commented 2 months ago

Good log :+1:

I see the scan start of the sdcard, but no folders are picked up:

2024-09-03T11:10:10.947Z  V/SDMSE:Gateway:Local: walk(AUTO->NORMAL, escalating): LocalPath(/storage/3334-3831)
2024-09-03T11:10:10.948Z  V/SDMSE:Gateway:Local: lookup(AUTO->NORMAL): LocalPath(/storage/3334-3831)

Only the internal one is picked up:

2024-09-03T11:10:10.973Z  V/SDMSE:Gateway:Local: lookupFiles(AUTO->NORMAL): LocalPath(/storage/emulated/0/Android)
2024-09-03T11:10:10.977Z  V/SDMSE:Gateway:Local: lookupFiles(AUTO->NORMAL): LocalPath(/storage/emulated/0/Example Folder)
2024-09-03T11:10:10.978Z  I/SDMSE:SystemCleaner:Crawler: Filter match: (EmptyDirectoryFilter(246644233), Deletion(lookup=LocalPathLookup(lookedUp=LocalPath(/storage/emulated/0/Example Folder), fileType=DIRECTORY, size=3452, modifiedAt=2024-09-03T11:10:01.035Z, target=null))) <- LocalPathLookup(lookedUp=LocalPath(/storage/emulated/0/Example Folder), fileType=DIRECTORY, size=3452, modifiedAt=2024-09-03T11:10:01.035Z, target=null)

I'll have to try and reproduce this.

Can you check two things?

SirNiklaas commented 2 months ago

I checked both things.

Storage Analyzer works as normal. Shows both Storages and I'm also able to go through all of its content, files and folders stored inside of it.

The custom system cleaner filter does also seem to work. After typing "Example" inside the box it already searched and found it. By running the tool itself with the filter enabled it also was able to find it like expected.

Also if it is any helpful for you, because it came to my mind that I recently upgraded my phone and I didn't quite remember to have that issue before. I just tested it on my older Samsung and got the same results with the same settings.

d4rken commented 2 months ago

Could reproduce it on Redmi A2 (Android 13).

The folders are matched initially, but then thrown out again

SDMSE:SystemCleaner:Crawler          V  Trying to match LocalPathLookup(lookedUp=LocalPath(/storage/8765-4321/Empty Directory), fileType=DIRECTORY, size=32768, modifiedAt=2024-09-05T15:03:41Z, target=null)
SDMSE:SystemClea...EmptyDirectories  V  Sieve match: /storage/8765-4321/Empty Directory
SDMSE:SystemCleaner:Crawler          V  Trying to match LocalPathLookup(lookedUp=LocalPath(/storage/8765-4321/eu.darken.sdmse-test-sd-area-access-local-5c941748-930f-4722-bb51-2d4a8ee7e12b), fileType=FILE, size=0, modifiedAt=2024-09-05T15:06:44Z, target=null)
SDMSE:SystemCleaner:Crawler          V  Trying to match LocalPathLookup(lookedUp=LocalPath(/storage/8765-4321/Empty), fileType=DIRECTORY, size=32768, modifiedAt=2024-09-05T15:03:15Z, target=null)
SDMSE:SystemClea...EmptyDirectories  V  Sieve match: /storage/8765-4321/Empty
SDMSE:SystemCleaner:Crawler          V  Trying to match LocalPathLookup(lookedUp=LocalPath(/storage/8765-4321/Directory), fileType=DIRECTORY, size=32768, modifiedAt=2024-09-05T15:03:16Z, target=null)
SDMSE:SystemClea...EmptyDirectories  V  Sieve match: /storage/8765-4321/Directory

Compared to internal storage:

SDMSE:SystemCleaner:Crawler          V  Trying to match LocalPathLookup(lookedUp=LocalPath(/storage/emulated/0/Download/Browser), fileType=DIRECTORY, size=3452, modifiedAt=2023-04-01T22:29:25.725Z, target=null)
SDMSE:SystemClea...EmptyDirectories  V  Sieve match: /storage/emulated/0/Download/Browser
SDMSE:Gateway:Local                  V  lookupFiles(AUTO->NORMAL): LocalPath(/storage/emulated/0/Download/Browser)
SDMSE:Gateway:Local                  V  Looked up 0 items:
SDMSE:SystemCleaner:Crawler          I  Filter match: (EmptyDirectoryFilter(149613740), Deletion(lookup=LocalPathLookup(lookedUp=LocalPath(/storage/emulated/0/Download/Browser), fileType=DIRECTORY, size=3452, modifiedAt=2023-04-01T22:29:25.725Z, target=null))) <- LocalPathLookup(lookedUp=LocalPath(/storage/emulated/0/Download/Browser), fileType=DIRECTORY, size=3452, modifiedAt=2023-04-01T22:29:25.725Z, target=null)

Now it becomes clear :thinking: the folder entry size is much larger on the sdcard, 32768 Byte vs 3452 Byte.

And this check then causes them to be ignored: https://github.com/d4rken-org/sdmaid-se/blob/345c5537627111472023ca63319127ff95298934/app/src/main/java/eu/darken/sdmse/systemcleaner/core/filter/stock/EmptyDirectoryFilter.kt#L121

So it depends on how the sdcard is formatted, how large the allocation sizes are.

d4rken commented 2 months ago

Should be fixed by #1384 with the next update. Thanks for the report :heart:

Screenshot_20240905_171718