remotestorage / remotestorage.js

⬡ JavaScript client library for integrating remoteStorage in apps
https://remotestoragejs.readthedocs.io
MIT License
2.31k stars 141 forks source link

client.getListing not returning full info #1108

Open rchrd2 opened 6 years ago

rchrd2 commented 6 years ago

The documentation makes me expect a response that has more info than just true. http://remotestoragejs.readthedocs.io/en/latest/js-api/base-client.html#list-of-functions

Am I doing something wrong, or is there a bug? This is "remotestoragejs@1.0.0",

client.getListing('') response:

{
    "test/": true,
    "demo.txt/": true,
    "apple.jpg": true,
    "styles/": true,
    "folder/": true,
    "views/": true,
    "js/": true
}

Actual API response

{
    "@context": "http://remotestorage.io/spec/folder-description",
    "items": {
        "test/": {
            "ETag": "857b527483cb0ee9fbe96c32523be949"
        },
        "demo.txt/": {
            "ETag": "65a42c26f75722109bad85246a15414a"
        },
        "apple.jpg": {
            "ETag": "98db258db75446f0aeebe10f761b97ff",
            "Content-Length": 4160,
            "Content-Type": "image/jpeg; charset=binary"
        },
        "styles/": {
            "ETag": "50e05011997701256c2e92fdbcbc209f"
        },
        "folder/": {
            "ETag": "a4391a6a61779554cd9af63145f72be6"
        },
        "views/": {
            "ETag": "1b30bdd77bff1373ce6665efd710d30c"
        },
        "js/": {
            "ETag": "635b3ed9a2f12b03b2ed71c21bc7497f"
        }
    }
}

Update:

The problem goes away when I disable local cache (IndexDB in my case)

new RemoteStorage({
  'cache': false,
});
raucao commented 6 years ago

The documentation you linked also shows true as only value for directory items. However, you're right about the objects, and the documentation is completely missing that information!

The story is that the cached data format hasn't been adapted yet, after the RS protocol changed the data available in listings a while back. It's a rather invasive change, and we both wanted to wait until the old protocol version was outdated enough (which is now the case), as well as refactor the caching and sync code first (which is currently in progress). Here's the original issue about it, incl. more information in the comment history: #721 (TL;DR: metadata is only stored on item nodes in cache, but getListing does a single request to the directory node)

I think it's high time we tackled this. Let's put it on the agenda for 1.1.0! Any takers, please self-assign the issue, or announce your working on it as a comment here. Thanks.

(Btw, you can upgrade rs.js to 1.0.2 already.)

raucao commented 6 years ago

The docs now contain a warning about this: https://remotestoragejs.readthedocs.io/en/latest/js-api/base-client.html#getListing

Thanks for bringing it up, @rchrd2!