Don't change usage counter on DELETE to non-existing resource

This commit is contained in:
Basti 2013-04-23 15:58:34 +02:00
parent 08661ea148
commit a35fef3727
2 changed files with 18 additions and 2 deletions

View File

@ -122,8 +122,10 @@ module RemoteStorage
riak_response = data_bucket.delete("#{user}:#{directory}:#{key}")
if riak_response[:code] != 404
log_object_count(user, directory, -1)
log_object_size(user, directory, 0, existing_object_size)
end
timestamp = (Time.now.to_f * 1000).to_i
delete_or_update_directory_objects(user, directory, timestamp)

View File

@ -374,6 +374,20 @@ describe "App with Riak backend" do
info_bucket.get("usage:jimmy:documents").data["count"].must_equal 999
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
before do
header "Content-Type", "image/jpeg; charset=binary"