Don't change usage counter on DELETE to non-existing resource
This commit is contained in:
parent
08661ea148
commit
a35fef3727
@ -122,8 +122,10 @@ module RemoteStorage
|
|||||||
|
|
||||||
riak_response = data_bucket.delete("#{user}:#{directory}:#{key}")
|
riak_response = data_bucket.delete("#{user}:#{directory}:#{key}")
|
||||||
|
|
||||||
|
if riak_response[:code] != 404
|
||||||
log_object_count(user, directory, -1)
|
log_object_count(user, directory, -1)
|
||||||
log_object_size(user, directory, 0, existing_object_size)
|
log_object_size(user, directory, 0, existing_object_size)
|
||||||
|
end
|
||||||
|
|
||||||
timestamp = (Time.now.to_f * 1000).to_i
|
timestamp = (Time.now.to_f * 1000).to_i
|
||||||
delete_or_update_directory_objects(user, directory, timestamp)
|
delete_or_update_directory_objects(user, directory, timestamp)
|
||||||
|
@ -374,6 +374,20 @@ describe "App with Riak backend" do
|
|||||||
info_bucket.get("usage:jimmy:documents").data["count"].must_equal 999
|
info_bucket.get("usage:jimmy:documents").data["count"].must_equal 999
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "non-existing object" do
|
||||||
|
before do
|
||||||
|
set_usage_info "jimmy", "documents", "size", 10
|
||||||
|
set_usage_info "jimmy", "documents", "count", 10
|
||||||
|
delete "/jimmy/documents/foozius"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't change the category usage info" do
|
||||||
|
usage = info_bucket.get("usage:jimmy:documents").data
|
||||||
|
usage["size"].must_equal 10
|
||||||
|
usage["count"].must_equal 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "binary data" do
|
context "binary data" do
|
||||||
before do
|
before do
|
||||||
header "Content-Type", "image/jpeg; charset=binary"
|
header "Content-Type", "image/jpeg; charset=binary"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user