Use-cases that we want to support regarding rescanning (written by David Flanagan):
0) Through DeviceStorage itself: Obviously, device storage will be able to track changes made through its own API.
1) MTP over USB This will be implemented (I think) as a client of DeviceStorage, so DeviceStorage will be able to track the changes and notify other clients of changed files.
2) Bluetooth FTP This will also be implemented as a client of DeviceStorage.
3) SD card insertion/removal while the phone is turned on: DeviceStorage could find out about this, rescan and notify clients. I don't think you'd even need a database for this case, since card removal would be deletion of files and card insertion would be creation of lots of new files. (This assumes that getDeviceStorage() returns an object representing the SD card filesystem even when no SD card is plugged in, so that clients can be notified when a card is plugged in).
4) SD card change while phone is off: I don't know how to handle this case. You'd have to rescan the SD card every time gecko starts up, I suppose.
5) USB Mass Storage Device: I gather that this gives unfettered access to the entire filesystem, so there is no way for device storage to track it other than by doing a complete rescan every time a USB mass storage session ends.
6) Are there any other ways (excluding bugs) that the contents of the device storage areas of a phone could change?
7) On the desktop, of course, all bets are off and you'd have to rescan every time gecko starts up if you want to be able to track changes, I suppose.
Do you guys have any practical examples for the DeviceStorageAPI at all?