Closed Bug 781358 Opened 12 years ago Closed 12 years ago

Default directories should be created on SD card

Categories

(Firefox OS Graveyard :: General, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: dhylands, Assigned: dougt)

Details

Attachments

(1 file)

Currently, DeviceStorage looks in folders like DCIM, Music, and Videos for files.

These folders should be created on the SD Card, if they don't already exist, each time the user inserts an SD card into the phone.
This would mean that every sdcard you insert into a B2G phone would have empty directories created.  I am not sure I like this very much.

What is the use case?
Currently, the way the DeviceStorage API is set up, different types of media have to go in particular directories.  If those directories do not exist, users will put their music collections (for example) in the wrong place, and the music app won't work.  This just happened to Dietrich, and he's a savvy user.

So we either have to get rid of special directories or make sure that those directories always exist when a card is mounted.
If https://bugzilla.mozilla.org/show_bug.cgi?id=781363 is fixed, then this one doesn't need to be.
I just ran across this issue. 
The problem would be frustrating because any app would not be able to assume that it would get a working DeviceStorage pointer back, even if the use case was just to store movies, music or pictures.  

Some apps would never work, and it wouldn't be clear why.  I am not advocating a specific solution, just how we should resolve this.   

Possibly by prompting the user whenever they try to get a device storage location that doesn't exist, whether they want to create.
blocking-basecamp: --- → ?
this is no longer a problem  -  device storage searches the entire sdcard.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → INVALID
blocking-basecamp: ? → ---
dougt could you detail how you would get a valid device storage object when you want to save a music file, and you have an empty sdcard.
i don't understand the question.  what specifically are you asking, or what do you want to do?
Excerpt mediadb.js

// If storage is null, then there is no sdcard installed and
// we have to abort.
mediadb.storage = navigator.getDeviceStorage(mediaType);

Doug the question I am asking is are there any scenarios other than an sdcard is not installed that mediadb.storage would == null.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
That line from mediadb.js is out of date.  And unrelated to the question of directories. On the device, the device storage type "pictures", "music" or "movies" no longer refers to a specific directory, but instead to a set of filename extensions.  So asking for device storage for "pictures" will scan the entire sdcard and find all .jpeg images (plus other image types, too, of course).  Directories are not relevant.  And device storage will never be null, despite the out of date code in mediadb.

dclarke: in comment 5, you said you ran across "this issue".  I'm curious to know what the symptom was. But it is is almost certainly a different bug.  This one should be closed, I think.
mediadb.storage would == null if mediaType was unrecognized, if the application didn't have the right permissions, if there was some other fatal error.  Also, what djf said.
So what I am doing is a bit off the beaten path, but I'll go through it so everyone is on the same page, also rebuilding my tree, as that might solve this issue. 

But what I am seeing is the following. 

1) I have a brand new "emulated" sd card running in the emulator "sdcard.img"
2) I have a mochitest which is attempting to add content / remove content from the sdcard.
3) I am creating a random blob, attaching a mime type 
4) Then I am calling addNamed, and hoping either success or error get triggered. 
5) I was unable to get a response to trigger, and wasn't exactly sure why. 


mediaTypes = ['music'];
mediaType = 0; 
mimeTypes = ['audio/mp3', 'video/mp4', 'image/jpg'];
prefix = mediaTypes[mediaType] ;
file = "abracadabra.mp3";

request = storage.addNamed(createRandomBlob(mimeTypes[mediaType]), prefix + '/' + file);
ok(request, "Should have a non-null request");
request.onsuccess = addSuccess;
request.onerror = addError;
Not enough space to store image on emulator with 1GB sdcard ?
ok need a new bug for this one .stat is returning 

console.log(e.target.result.freeBytes);

E/GeckoConsole(  216): Content JS LOG at app://camera.gaiamobile.org/js/camera.js:400 in anonymous: 54044

Basically i think the problem is in the translation from C++ -> Javascript probably need to use some mechanism to preserve that this is a very large number.
okay, just a bit of debugging and printfs... i know what this is.  Patching coming up.
Assignee: nobody → doug.turner
well, this is clearly a different bug.  I am marking this bug as invalid (as we don't need to create directories).  I'll open a new bug about freeBytes being wrong.
Status: REOPENED → RESOLVED
Closed: 12 years ago12 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: