remotestorage / spec

remoteStorage Protocol Specification
https://tools.ietf.org/html/draft-dejong-remotestorage
87 stars 5 forks source link

Improve Format of Directory Listings #26

Closed waldheinz closed 10 years ago

waldheinz commented 11 years ago

I think the JSON format of directory listings can (and should) be improved. From the current spec, a directory is listed like this:

{
  "abc": "DEADBEEFDEADBEEFDEADBEEF",
  "def/": "1337ABCD1337ABCD1337ABCD"
}

The problems I see with this are, in no particular order:

Therefore I'd like to suggest a response format like this:

{ "contents" :
  [ { "name" : "abc",  "tag" : "DEADBEEFDEADBEEFDEADBEEF" }
  , { "name" : "def/", "tag" : "1337ABCD1337ABCD1337ABCD" }
  ]
}

The proposed format

I don't consider my proposal "final", e.g. if it's called contents or items or whatever is not the scope of this post, it's just about the general structure. Maybe it's a good idea to add a version property to the top-level object, I don't really have an opinion about this.

michielbdejong commented 11 years ago

i think the driving argument here should be performance issues in the fuse client. i'm reluctant to make any changes at all to the spec unless they come from a real-world impact on user experience. sorry to be such a [insert historict strict person] about this

waldheinz commented 11 years ago

I did not mean that the directory listings should contain schemas for the listed entries, but I meant that there is (and cannot be) a schema for the directory listing itself. Otherwise I agree that there is no immediate need for action here, but I think it's worth keeping an eye on this because of the limitations of the current format.

So, if for some reason a breaking change has to be done anyway, this could be slipped in with no additional effort.

michielbdejong commented 11 years ago

ah right, yeah that makes more sense. so then it would become something like

{
  "@context": '"http://remotestorage.io/2013/directory-listing",
   "items": {
    "foo": "1",
    "bar/": "8"
  }
}

good point!

waldheinz commented 11 years ago

While we're at it, I'd rather go for something like

{ "@context" : "http://remotestorage.io/2013/directory-listing",
  "items" :
    [ { "name" : "abc",  "tag" : "DEADBEEFDEADBEEFDEADBEEF" }
    , { "name" : "def/", "tag" : "1337ABCD1337ABCD1337ABCD" }
    ]
}

But otherwise, yes, that's what I meant.

nilclass commented 11 years ago

And possibly also:

{ "@context" : "http://remotestorage.io/2013/directory-listing",
  "items" :
    [ { "name" : "abc",  "tag" : "DEADBEEFDEADBEEFDEADBEEF", "type": "text/plain" }
    , { "name" : "def/", "tag" : "1337ABCD1337ABCD1337ABCD", "type": "application/json" }
    ]
}
steventebrinke commented 11 years ago

The proposed structure looks fine to me, it certainly is more extensible than the current structure. It seems that the purpose is mainly to give more information in the directory listing, instead of using additional HEAD requests. If that's the purpose, IMO, it would be easiest if all property names are the same as the HTTP headers. (Since HTTP headers are case insensitive, requiring property names to be lowercase might be good). For example:

{ "@context" : "http://remotestorage.io/2013/directory-listing",
  "items" :
    [ { "location" : "abc",  "etag" : "DEADBEEFDEADBEEFDEADBEEF", "content-type": "text/plain" }
    , { "location" : "def/", "etag" : "1337ABCD1337ABCD1337ABCD", "content-type": "application/json" }
    ]
}

This makes it very extensible, since any HTTP header can be used. A schema would not really be required, if specified that the meaning of each property is equivalent to that of the HTTP header, but a schema could, for example, specify that both location and etag are required and all other properties are optional.

waldheinz commented 11 years ago

I would rather not bind the format of the directory listing to the underlying transport (i.e. HTTP right now). This might cause trouble if another transport is used, like local file access or WebSockets or whatever might come.

steventebrinke commented 11 years ago

I don't see why that would be a problem, since the whole protocol is built on top of HTTP, so for another transport, a major revision is required anyway. Besides that, even when another transport is used, names can still be mapped to the ones used by HTTP.

michielbdejong commented 11 years ago

let's do it like https://github.com/remotestorage/spec/issues/26#issuecomment-22315722 in -02, that is the minimal change that makes us able to say we're part of the linked data revolution

michielbdejong commented 11 years ago

oh, and combine it with https://github.com/remotestorage/spec/issues/16

michielbdejong commented 10 years ago

postponing until -03, due to lack of people to who would have time to implement this right now.

raucao commented 10 years ago

I would do it. And I badly need it for 2 apps I'm working on. And I guess I'm not the only one, since basically everybody except you wanted to have it during the unconf, including a core maintainer.

raucao commented 10 years ago

Also, does anybody have any problem with @steventebrinke's proposed format? I think it would be a great solution.

michielbdejong commented 10 years ago

done