karip / harbour-file-browser

A native file browser to view files on Sailfish phones.
The Unlicense
21 stars 19 forks source link

sd card access does not work with SailfishOS update 4 #2

Closed foolab closed 9 years ago

foolab commented 10 years ago

sd card is now mounted under /media/sdcard and the mount point is named after the UUID of the sd card which means the old hardcoded sd card path does not work anymore.

An idea would be to parse /proc/mounts or checking all directories under /media/sdcard and see which one corresponds to a mount point. There is not yet a supported Sailfish API for detecting the cards (QStorageInfo should work though but it might not be white listed).

Please note that there can be multiple mounted partitions under /media/sdcard if the card itself has multiple partitions.

karip commented 10 years ago

Hi and thanks for raising this issue.

QStorageInfo would be the ideal solution, but according to Jolla "We're currently investigating if QStorageInfo is fully suitable for providing SD card access, and will update developer FAQs once done." https://lists.sailfishos.org/pipermail/devel/2014-March/003724.html

So, I would suggest a quick and dirty fix now and then perhaps properly fixing it once Jolla has investigated QStorageInfo.

My proposal to fix this is to check how many directories /media/sdcard has. If it has only one, then it is used as the SD Card directory. If there are several directories (case of multiple partitions), then the /media/sdcard directory is used and the user needs to manually select the partition.

In 99% of the cases people are going to have only one partition, so it would make sense to go straight to it. Also, I don't think many will be manually creating extra directories under /media/sdcard.

What do you think of this approach? Or should it also check that the directories are actually mount points?

The latest version of the app (not yet available in the Jolla store) is also showing the space available on the SD Card by running the du shell command. In one partition case, it could just show the space on that one partition. On multiple partition case, perhaps it shouldn't show anything. Any comments about that?

I could actually use the du command output to determine the sd card mount point. Let's see if it is easy to do..

foolab commented 10 years ago

We leave the directories behind when we unmount them so you can't assume they are all mount points. I guess a matching against /proc/mounts would be the ideal way. You can also get the names of all the directories under /media/sdcard/ and check /dev/disk/by-uuid/ for the existence of such directories I guess.

Another idea if you feel like it is to use glib GVolumeMonitor. It's the same code used by tracker so it should work fine and glib is whitelisted. I can help with that part if needed.

I'd do it that way: If there is 1 partition mounted then move to it. If more then I'd show a dialog that allows the user to select which partition should be used. What do you think?

karip commented 10 years ago

I have now modified the app to get all dirs under /media/sdcard and to parse and match against /proc/mounts. The change is available in github and you can see the changes in Engine::sdcardPath().

If there are several partitions, it just goes to /media/sdcard. The user can then select the correct folder. So, it kind of functions as a dialog...

And thanks for telling me that the directories are left behind and how to check against /proc/mounts. I wouldn't have known about those.