Public
Authored by Shivansh Saini

Weird behaviour

From the print statement in StorageProvider.kt

/tmp/junit3921508329320678908/custom1 | /tmp/xxxx/external-cache
/tmp/junit3921508329320678908/custom1 | /tmp/junit3921508329320678908/custom1
/tmp/xxxx/external-cache/custom2 | /tmp/xxxx/external-cache // <-- the problematic one
/tmp/xxxx/external-cache/custom2 | /tmp/junit3921508329320678908/custom1
/tmp/xxxx/external-cache/custom2 | /tmp/xxxx/external-cache/custom2

This line - if (customDir.path.startsWith(mediaDirLocation)) continue@customLoop should imply that custom2 directory won't be considered since it starts with the mediaDirLocation in one place. However, down the iterations, eventually it stumbles upon /tmp/junit3921508329320678908/custom1 in mediaDirLocation and so includes it. Is it an intentional behaviour? Since I assumed that the StorageProvider should skip stuff which would come in nested directory anyways..

Edited
StorageProvider + DirectoryRepository 1.08 KB
  • I don't get it. What is in customDirectories and what's not?

    which folder are included in the end?

  • customDirectories is supposed to contain user-added directories to be scanned by medialibrary. And the getMediaDirectories method of DirectoryRepository also includes it.. Now, it's fetched again by StorageProvider in customDirectories and merged with storages in such a way that it only appears once in the storagesList.

  • However, I am confused about those custom directories which are children of already included directories in storages, like Internal Storage. What the logic implies is that they shouldn't be considered in storagesList. However, they actually are considered. So, I wanted to confirm is this intentional behavior?

  • Since I guess I'm not clear, here's a screenshot:

    Include Directories for Medialibrary scan

    Edited by Shivansh Saini
  • airmore directory is inside Internal Storages. Internal Storages can be added as custom directory, however it shows in the list maximum of two times.

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment