Along with these changes, I would like to promote Dave Hylands and Jan
Varga to owners of the device storage code. I am stepping away from
this area of code due to other responsibilities. The world (or at least
this code) is a better places with these two folks at the helm.
Doug
Dave Hylands wrote:
So bug 858416 has been landed on birch and it should make its way to b2g18.
I wanted to summarize the changes that have occurred in the device storage API.
In order to support both internal and external storage areas, we've added
support for what I call composite device storage objects.
In the past a name like DCIM/car.jpg would be sufficient to uniquely identify a
file. However when there are multiple device storage areas, this doesn't tell
you which storage area the file is stored in.
So, a "fully qualified" name now looks like
/storageName/directory/file
While storageName looks like a directory component, it isn't, it's the name of
a volume. Typical volume names might be sdcard and extsdcard, so a fully
qualified name would look like:
/sdcard/directory/file
/extsdcard/directory/file
navigator.getDeviceStorage(type) now returns what I call a composite device
storage object.
navigator.getDeviceStorages(type) returns an array of non-composite storage
objects. It is anticipated that this particular API would only be used by the
settings app for displaying free/used space for each volume. Each non-composite
device storage object has an attribute called storageName which identifies the
volume that the device storage area corresponds to.
When using the composite device storage object, If you call AddNamed and were to specify
"DCIM/foo.jpg" then it will use the default storage area (set by the user in
the settings app under Media Storage).
The onsuccess method will be passed the fully qualified name of the object
(i.e. you'd probably get back something like /sdcard/DCIM/foo.jpg).
Enumerate has changed slightly as well. Previously if you called
enumerate('DCIM') you'd get back just the portion of the filename below the
DCIM directory (so just foo.jpg). Now, you always get back a fully qualified
location (/sdcard/DCIM/foo.jpg). When you use enumerate on the composite device
storage object, it will return all of the files on all of the storage areas.
Calling freeSpace or usedSpace on the composite object will return a sum of the
free or used space over all of the volumes. Calling available on the composite
object will return a composite availability.
So if any volume is available, you'll get back "available". If no volumes are available, and any
are shared, then then you'll get back "shared", otherwise you'll get back "unavailable".
If you call available on a non-composite object it will return the availability
for that particular storage area.
I'm sure I've broken some stuff, but the basics seem to work, i.e. I can take a
picture, and see it in gallery, and I can see music etc. I'll be working next
week to more exhaustively test all of the areas which I may have otherwise
missed.
Dave Hylands
_______________________________________________
dev-b2g mailing list
dev-b2g@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-b2g