diff --git a/lib/remote_storage/swift.rb b/lib/remote_storage/swift.rb index 9a531ff..d104f11 100644 --- a/lib/remote_storage/swift.rb +++ b/lib/remote_storage/swift.rb @@ -126,13 +126,20 @@ module RemoteStorage if string.sub(name, -1) ~= "/" then listing[name]["Content-Type"] = metadata["t"] listing[name]["Content-Length"] = tonumber(metadata["s"]) + listing[name]["Last-Modified"] = tonumber(metadata["m"]) end end return cjson.encode(listing) 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 def put_data(user, directory, key, data, content_type) diff --git a/spec/swift/app_spec.rb b/spec/swift/app_spec.rb index ae29074..ae207c7 100644 --- a/spec/swift/app_spec.rb +++ b/spec/swift/app_spec.rb @@ -152,6 +152,7 @@ describe "App" do 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-Length"].must_equal 8 + content["items"]["bamboo.txt"]["Last-Modified"].must_equal "Fri, 04 Mar 2016 12:20:18 GMT" end end