Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ system. Old cached data will be converted to the new format automatically.

* `getAll` and `getListing` now return an empty object instead of undefined when no items
match the query
* `getListing` no longer includes Content-Type information; use `getFile` for that now.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how that is in any way related. The whole idea of getting the info with a listing, is so that you don't have to download the file to get that info.

I think it should read something like:

Object meta data has been removed from the getListing response, until we have a better implementation (#652, #720, #721)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

* `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`
Expand Down
17 changes: 11 additions & 6 deletions src/baseclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
*
* A BaseClient deals with three types of data: folders, objects and files.
*
* <getListing> 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.
* <getListing> 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
* }
*
* <getObject> / <storeObject> operate on JSON objects. Each object has a type.
*
Expand Down Expand Up @@ -199,9 +202,11 @@
* Example:
* (start code)
* client.getListing('', false).then(function(listing) {
* listing.forEach(function(item) {
* console.log(item);
* });
* //listing is for instance:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make sense. You just put a random object in a function in usable example code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed (if I understood your objection correctly)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, now it's usable, but I found the old example better somehow. But that's just me.

* {
* 'folder/': true,
* 'document.txt': true
* };
* });
* (end code)
*/
Expand Down
7 changes: 7 additions & 0 deletions src/cachinglayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@
this.getNodes([path]).then(function(objs) {
var node = getLatest(objs[path]);
if (node) {
if (isFolder(path)) {
for (var i in node.itemsMap) {
if (node.itemsMap[i] === false) {
delete node.itemsMap[i];
}
}
}
promise.fulfill(200, node.body || node.itemsMap, node.contentType);
} else {
promise.fulfill(404);
Expand Down
27 changes: 27 additions & 0 deletions test/unit/inmemorycaching-suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down