Save directory metadata in redis (WIP)
This commit is contained in:
parent
990ea9cf28
commit
cd2c0865e8
@ -265,7 +265,7 @@ module RemoteStorage
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_metadata_object(user, directory, key, metadata)
|
def update_metadata_object(user, directory, key, metadata)
|
||||||
key = "users:#{user}:data:#{directory}/#{key}"
|
key = "rs_meta:#{user}:#{directory}/#{key}"
|
||||||
redis.hmset(key, *metadata)
|
redis.hmset(key, *metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -274,7 +274,10 @@ module RemoteStorage
|
|||||||
timestamp = (Time.now.to_f * 1000).to_i
|
timestamp = (Time.now.to_f * 1000).to_i
|
||||||
|
|
||||||
parent_directories_for(directory).each do |dir|
|
parent_directories_for(directory).each do |dir|
|
||||||
do_put_request("#{url_for_directory(user, dir)}/", timestamp.to_s, "text/plain")
|
res = do_put_request("#{url_for_directory(user, dir)}/", timestamp.to_s, "text/plain")
|
||||||
|
key = "rs_meta:#{user}:#{dir}/"
|
||||||
|
metadata = {etag: res.headers[:etag], modified: timestamp}
|
||||||
|
redis.hmset(key, *metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -17,7 +17,6 @@ describe "App" do
|
|||||||
before do
|
before do
|
||||||
redis.sadd "authorizations:phil:amarillo", [":rw"]
|
redis.sadd "authorizations:phil:amarillo", [":rw"]
|
||||||
header "Authorization", "Bearer amarillo"
|
header "Authorization", "Bearer amarillo"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates the metadata object in redis" do
|
it "creates the metadata object in redis" do
|
||||||
@ -28,12 +27,26 @@ describe "App" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
metadata = redis.hgetall "users:phil:data:food/aguacate"
|
metadata = redis.hgetall "rs_meta:phil:food/aguacate"
|
||||||
metadata["size"].must_equal "2"
|
metadata["size"].must_equal "2"
|
||||||
metadata["type"].must_equal "text/plain; charset=utf-8"
|
metadata["type"].must_equal "text/plain; charset=utf-8"
|
||||||
metadata["etag"].must_equal "bla"
|
metadata["etag"].must_equal "bla"
|
||||||
metadata["modified"].must_equal nil
|
metadata["modified"].must_equal nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "creates the directory objects metadata in redis" do
|
||||||
|
put_stub = OpenStruct.new(headers: {etag: "bla"})
|
||||||
|
RemoteStorage::Swift.stub_any_instance :has_name_collision?, false do
|
||||||
|
RestClient.stub :put, put_stub do
|
||||||
|
put "/phil/food/aguacate", "si"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
metadata = redis.hgetall "rs_meta:phil:food/"
|
||||||
|
metadata["etag"].must_equal "bla"
|
||||||
|
metadata["modified"].length.must_equal 13
|
||||||
|
metadata = redis.hgetall "rs_meta:phil:food/"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user