diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fa9d247c..f856ba5c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,9 @@ system. Old cached data will be converted to the new format automatically. ### Breaking changes * `getAll` and `getListing` now return an empty object instead of undefined when no items - match the query + match the query +* Object meta data has been removed from the `getListing` response, until we have a better + implementation (#652, #720, #721) * `disconnect` event removed in favor of `disconnected` * `remoteStorage.claimAccess` removed in favor of `remoteStorage.access.claim` * `BaseClient#use` and `BaseClient#release` removed in favor of `BaseClient#cache` @@ -23,12 +25,12 @@ system. Old cached data will be converted to the new format automatically. * Major rewrite of the tree-based sync and caching system * Performance was improved, especially when storing many small objects * A new `maxAge` parameter is available in the various BaseClient get... - functions, where you can specify the maximum age of cached results (in ms). - This replaces the ready-queue from 0.9.0. + functions, where you can specify the maximum age of cached results (in ms). + This replaces the ready-queue from 0.9.0. * Caching of subtrees can now be configured as 'ALL', 'SEEN', or 'FLUSH'. The second - one means documents that were seen once, will stay synced. Check the - [caching documentation](http://remotestorage.io/doc/code/files/caching-js.html) - for details. `caching.enable(path)` will use 'ALL' by default. + one means documents that were seen once, will stay synced. Check the + [caching documentation](http://remotestorage.io/doc/code/files/caching-js.html) + for details. `caching.enable(path)` will use 'ALL' by default. * Add and use background sync interval, based on Page Visibility API (#462) * Choose from which origins change events are emitted via `RemoteStorage.config.changeEvents` * More unit tests @@ -69,7 +71,7 @@ in the next release via https://github.com/remotestorage/remotestorage.js/issues * Label change events from initial sync as 'local' if they come from local * Add JSHint config * Add in-memory storage for when neither IndexedDB nor localStorage are - available + available * Move the example server and example apps to gh:remotestorage/starter-kit * Add setSyncInterval method * Add i18n module, enable translation/customization of all content strings @@ -87,10 +89,10 @@ in the next release via https://github.com/remotestorage/remotestorage.js/issues * Size reduced by almost 25%, to 34K minified, gzipped * Fixes issues with non-ASCII characters in item names * Fixes unnecessary polling of documents whose entry in the parent directory - did not change + did not change * Widget fixes * Compatible with [remotestorage-02](https://github.com/remotestorage/spec/blob/master/draft-dejong-remotestorage-head.txt) - (although nothing needed to change for this) + (although nothing needed to change for this) ## 0.8.1 (August 2013) @@ -121,9 +123,9 @@ in the next release via https://github.com/remotestorage/remotestorage.js/issues * Made validation schemas global (schemas from other modules can be referred to using: /) * Added 'inspect' debug widget. If debug support is built in, use remoteStorage.inspect() in your app to try it. * Deprectated the "util" part. It contained a lot of utility functions that bloated the library and are also - available in the same or similar form from third-party libraries. - Until the next major release a subset of the "util" object will still be available (see "src/legacy.js" for - a list of methods that are included). + available in the same or similar form from third-party libraries. + Until the next major release a subset of the "util" object will still be available (see "src/legacy.js" for + a list of methods that are included). ## 0.7.0 (January 2013) diff --git a/src/baseclient.js b/src/baseclient.js index 1ac57ed65..3a0689bea 100644 --- a/src/baseclient.js +++ b/src/baseclient.js @@ -14,9 +14,12 @@ * * A BaseClient deals with three types of data: folders, objects and files. * - * returns a list of all items within a folder, or undefined - * if a 404 is encountered. Items that end with a forward slash ("/") are - * child folders. + * returns a mapping of all items within a folder. Items that + * end with a forward slash ("/") are child folders. For instance: + * { + * 'folder/': true, + * 'document.txt': true + * } * * / operate on JSON objects. Each object has a type. * @@ -199,9 +202,11 @@ * Example: * (start code) * client.getListing('', false).then(function(listing) { - * listing.forEach(function(item) { - * console.log(item); - * }); + * // listing is for instance: + * // { + * // 'folder/': true, + * // 'document.txt': true + * // } * }); * (end code) */ diff --git a/src/cachinglayer.js b/src/cachinglayer.js index 04431e6ac..d617c9c33 100644 --- a/src/cachinglayer.js +++ b/src/cachinglayer.js @@ -174,6 +174,14 @@ this.getNodes([path]).then(function(objs) { var node = getLatest(objs[path]); if (node) { + if (isFolder(path)) { + for (var i in node.itemsMap) { + // the hasOwnProperty check here is only because our jshint settings require it: + if (node.itemsMap.hasOwnProperty(i) && node.itemsMap[i] === false) { + delete node.itemsMap[i]; + } + } + } promise.fulfill(200, node.body || node.itemsMap, node.contentType); } else { promise.fulfill(404); diff --git a/test/unit/inmemorycaching-suite.js b/test/unit/inmemorycaching-suite.js index 9668cb119..2c8f737fe 100644 --- a/test/unit/inmemorycaching-suite.js +++ b/test/unit/inmemorycaching-suite.js @@ -113,6 +113,33 @@ define(['requirejs'], function(requirejs) { } }, + { + desc: "#get removes falsy items from local version itemsMap", + run: function(env, test) { + var requestQueued = false; + var oldTimestamp = (new Date().getTime()) - 1000; + + env.rs.local._storage['/'] = { + path: '/', + common: { + itemsMap: { foo: true, bar: true }, + timestamp: oldTimestamp, + revision: '123' + }, + local: { + itemsMap: { foo: true, bar: false }, + timestamp: oldTimestamp, + revision: '123' + } + }; + env.rs.local.get('/', false).then(function(status, itemsMap) { + test.assertAnd(status, 200); + test.assertAnd(itemsMap, { foo: true }); + test.done(); + }); + } + }, + { desc: "#get gets queued as a sync request if node is older than the maxAge", run: function(env, test) {