Add Last-Modified date to document items in listings
Not in RS spec draft yet, see https://github.com/remotestorage/spec/issues/158 for discussion.
This commit is contained in:
parent
c11310381a
commit
60c508fba9
@ -126,13 +126,20 @@ module RemoteStorage
|
|||||||
if string.sub(name, -1) ~= "/" then
|
if string.sub(name, -1) ~= "/" then
|
||||||
listing[name]["Content-Type"] = metadata["t"]
|
listing[name]["Content-Type"] = metadata["t"]
|
||||||
listing[name]["Content-Length"] = tonumber(metadata["s"])
|
listing[name]["Content-Length"] = tonumber(metadata["s"])
|
||||||
|
listing[name]["Last-Modified"] = tonumber(metadata["m"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return cjson.encode(listing)
|
return cjson.encode(listing)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
JSON.parse(redis.eval(lua_script, nil, [user, directory]))
|
items = JSON.parse(redis.eval(lua_script, nil, [user, directory]))
|
||||||
|
|
||||||
|
items.reject{|k, _| k.end_with? "/"}.each do |_, v|
|
||||||
|
v["Last-Modified"] = Time.at(v["Last-Modified"]/1000).httpdate
|
||||||
|
end
|
||||||
|
|
||||||
|
items
|
||||||
end
|
end
|
||||||
|
|
||||||
def put_data(user, directory, key, data, content_type)
|
def put_data(user, directory, key, data, content_type)
|
||||||
|
@ -152,6 +152,7 @@ describe "App" do
|
|||||||
content["items"]["bamboo.txt"]["ETag"].must_equal "bla"
|
content["items"]["bamboo.txt"]["ETag"].must_equal "bla"
|
||||||
content["items"]["bamboo.txt"]["Content-Type"].must_equal "text/plain; charset=utf-8"
|
content["items"]["bamboo.txt"]["Content-Type"].must_equal "text/plain; charset=utf-8"
|
||||||
content["items"]["bamboo.txt"]["Content-Length"].must_equal 8
|
content["items"]["bamboo.txt"]["Content-Length"].must_equal 8
|
||||||
|
content["items"]["bamboo.txt"]["Last-Modified"].must_equal "Fri, 04 Mar 2016 12:20:18 GMT"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user