Closed Bug 1068933 Opened 10 years ago Closed 10 years ago

DeviceStorage - since not working properly with enumerate

Categories

(Core :: DOM: Device Interfaces, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
2.1 S7 (24Oct)

People

(Reporter: dhylands, Assigned: dhylands)

Details

Attachments

(1 file, 1 obsolete file)

I added the following function to ds-test:

> function ds_test_enumerate_since() {
>   log('ds_test_enumerate_since');
>
>   var storage = navigator.getDeviceStorage('sdcard');
>   var cursor = storage.enumerate();
>   var timestamp = null
>   var do_since = true;
>   cursor.onsuccess = function enumSuccess(e) {
>     if (e.target.result == null) {
>       if (do_since) {
>         do_since = false;
>         if (timestamp) {
>           log('===== since.txt timestamp = ' + timestamp + ' =====');
>           var cursor_since = storage.enumerate({'since' : timestamp});
>           cursor_since.onsuccess = cursor.onsuccess;
>           cursor_since.onerror = cursor.onerror;
>         } else {
>           log("since.txt file not found");
>         }
>       } else {
>         log('===== Done =====');
>       }
>       return;
>     }
>     log(e.target.result.name + ' - ' + e.target.result.lastModifiedDate);
>     if (e.target.result.name.slice(-9) == 'since.txt') {
>       timestamp = e.target.result.lastModifiedDate;
>     }
>     e.target.continue();
>   };
>   cursor.onerror = function enumError(e) {
>     log('enumError');
>   };
> }

If I then take a few pictures, and then do:
> adb shell touch /storage/sdcard0/DCIM/100MZLLA/since.txt
and then take a few more pictures, I get this output:

> /sdcard/DCIM/100MZLLA/IMG_0009.jpg - Wed Sep 17 2014 12:42:14 GMT-0700 (UTC)
> /sdcard/DCIM/100MZLLA/IMG_0010.jpg - Wed Sep 17 2014 12:42:18 GMT-0700 (UTC)
> /sdcard/DCIM/100MZLLA/since.txt    - Wed Sep 17 2014 12:43:38 GMT-0700 (UTC)
> /sdcard/DCIM/100MZLLA/IMG_0011.jpg - Wed Sep 17 2014 12:44:00 GMT-0700 (UTC)
> /sdcard/DCIM/100MZLLA/IMG_0012.jpg - Wed Sep 17 2014 12:44:04 GMT-0700 (UTC)
> ===== since.txt timestamp = Wed Sep 17 2014 12:43:38 GMT-0700 (UTC) =====
> ===== Done =====

It should report IMG_0011.jpg and IMG_0012.jpg from the since enumeration and it doesn't.

There is a similar test case for this in:
http://dxr.mozilla.org/mozilla-central/source/dom/devicestorage/test/test_lastModificationFilter.html?from=test_lastModificationFilter.html#1

so I need to figure out why the test is working (or not being run, or whatever) and why the code I posted above isn't working.
Target Milestone: --- → 2.1 S5 (26sep)
DeviceStorage only returns files, so it should only be filtering files.

The way it was implemented it would discard entire directory trees if the timestamp on the directory was less than the since modifier.
Updated the last filter test.
Verified that the test fails without the rest of the patch and pass with the patch.
Attachment #8491182 - Attachment is obsolete: true
Attachment #8491218 - Flags: review?(Jan.Varga)
Any ETA on the review?
Flags: needinfo?(Jan.Varga)
sorry, I was finishing something else, will do tomorrow
Flags: needinfo?(Jan.Varga)
Comment on attachment 8491218 [details] [diff] [review]
Only look at timestamps of files (not directories) v2

Review of attachment 8491218 [details] [diff] [review]:
-----------------------------------------------------------------

sorry for the delay
Attachment #8491218 - Flags: review?(Jan.Varga) → review+
Target Milestone: 2.1 S5 (26sep) → 2.1 S7 (24Oct)
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: