Fix deleting metadata for empty subdirectories
This commit is contained in:
@@ -341,8 +341,8 @@ module RemoteStorage
|
|||||||
|
|
||||||
parent_directories_for(directory).each do |dir|
|
parent_directories_for(directory).each do |dir|
|
||||||
if dir_empty?(user, dir)
|
if dir_empty?(user, dir)
|
||||||
redis.del "rs:m:#{user}:#{directory}/"
|
redis.del "rs:m:#{user}:#{dir}/"
|
||||||
redis.srem "rs:m:#{user}:#{parent_directory_for(dir)}:items", "#{dir}/"
|
redis.srem "rs:m:#{user}:#{parent_directory_for(dir)}:items", "#{top_directory(dir)}/"
|
||||||
else
|
else
|
||||||
etag = etag_for(dir, timestamp)
|
etag = etag_for(dir, timestamp)
|
||||||
|
|
||||||
|
|||||||
@@ -186,23 +186,14 @@ describe "App" do
|
|||||||
RestClient.stub :put, put_stub do
|
RestClient.stub :put, put_stub do
|
||||||
put "/phil/food/aguacate", "si"
|
put "/phil/food/aguacate", "si"
|
||||||
put "/phil/food/camaron", "yummi"
|
put "/phil/food/camaron", "yummi"
|
||||||
|
put "/phil/food/desunyos/bolon", "wow"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "deletes the metadata object in redis" do
|
it "deletes the metadata object in redis" do
|
||||||
put_stub = OpenStruct.new(headers: {
|
RestClient.stub :delete, "" do
|
||||||
etag: "bla",
|
RemoteStorage::Swift.stub_any_instance :etag_for, "rootetag" do
|
||||||
last_modified: "Fri, 04 Mar 2016 12:20:18 GMT"
|
delete "/phil/food/aguacate"
|
||||||
})
|
|
||||||
get_stub = OpenStruct.new(body: "rootbody")
|
|
||||||
|
|
||||||
RestClient.stub :put, put_stub do
|
|
||||||
RestClient.stub :delete, "" do
|
|
||||||
RestClient.stub :get, get_stub do
|
|
||||||
RemoteStorage::Swift.stub_any_instance :etag_for, "rootetag" do
|
|
||||||
delete "/phil/food/aguacate"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -213,19 +204,9 @@ describe "App" do
|
|||||||
it "deletes the directory objects metadata in redis" do
|
it "deletes the directory objects metadata in redis" do
|
||||||
old_metadata = redis.hgetall "rs:m:phil:food/"
|
old_metadata = redis.hgetall "rs:m:phil:food/"
|
||||||
|
|
||||||
put_stub = OpenStruct.new(headers: {
|
RestClient.stub :delete, "" do
|
||||||
etag: "bla",
|
RemoteStorage::Swift.stub_any_instance :etag_for, "newetag" do
|
||||||
last_modified: "Fri, 04 Mar 2016 12:20:18 GMT"
|
delete "/phil/food/aguacate"
|
||||||
})
|
|
||||||
get_stub = OpenStruct.new(body: "rootbody")
|
|
||||||
|
|
||||||
RestClient.stub :put, put_stub do
|
|
||||||
RestClient.stub :delete, "" do
|
|
||||||
RestClient.stub :get, get_stub do
|
|
||||||
RemoteStorage::Swift.stub_any_instance :etag_for, "newetag" do
|
|
||||||
delete "/phil/food/aguacate"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -235,38 +216,28 @@ describe "App" do
|
|||||||
metadata["m"].wont_equal old_metadata["m"]
|
metadata["m"].wont_equal old_metadata["m"]
|
||||||
|
|
||||||
food_items = redis.smembers "rs:m:phil:food/:items"
|
food_items = redis.smembers "rs:m:phil:food/:items"
|
||||||
food_items.must_equal ["camaron"]
|
food_items.must_equal ["desunyos/", "camaron"]
|
||||||
|
|
||||||
root_items = redis.smembers "rs:m:phil:/:items"
|
root_items = redis.smembers "rs:m:phil:/:items"
|
||||||
root_items.must_equal ["food/"]
|
root_items.must_equal ["food/"]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "deletes the parent directory objects metadata when deleting all items" do
|
it "deletes the parent directory objects metadata when deleting all items" do
|
||||||
put_stub = OpenStruct.new(headers: {
|
RestClient.stub :delete, "" do
|
||||||
etag: "bla",
|
RemoteStorage::Swift.stub_any_instance :etag_for, "rootetag" do
|
||||||
last_modified: "Fri, 04 Mar 2016 12:20:18 GMT"
|
delete "/phil/food/aguacate"
|
||||||
})
|
delete "/phil/food/camaron"
|
||||||
get_stub = OpenStruct.new(body: "rootbody")
|
delete "/phil/food/desunyos/bolon"
|
||||||
|
|
||||||
RestClient.stub :put, put_stub do
|
|
||||||
RestClient.stub :delete, "" do
|
|
||||||
RestClient.stub :get, get_stub do
|
|
||||||
RemoteStorage::Swift.stub_any_instance :etag_for, "rootetag" do
|
|
||||||
delete "/phil/food/aguacate"
|
|
||||||
delete "/phil/food/camaron"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
metadata = redis.hgetall "rs:m:phil:food/"
|
redis.smembers("rs:m:phil:food/desunyos:items").must_be_empty
|
||||||
metadata.must_be_empty
|
redis.hgetall("rs:m:phil:food/desunyos/").must_be_empty
|
||||||
|
|
||||||
food_items = redis.smembers "rs:m:phil:food/:items"
|
redis.smembers("rs:m:phil:food/:items").must_be_empty
|
||||||
food_items.must_be_empty
|
redis.hgetall("rs:m:phil:food/").must_be_empty
|
||||||
|
|
||||||
root_items = redis.smembers "rs:m:phil:/:items"
|
redis.smembers("rs:m:phil:/:items").must_be_empty
|
||||||
root_items.must_be_empty
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user