Don't write any opslog when count and size didn't change (same file)
This commit is contained in:
parent
2f95aab874
commit
17068f33df
@ -173,11 +173,14 @@ module RemoteStorage
|
|||||||
end
|
end
|
||||||
|
|
||||||
def log_operation(user, directory, count, new_size=0, old_size=0)
|
def log_operation(user, directory, count, new_size=0, old_size=0)
|
||||||
|
size = (-old_size + new_size)
|
||||||
|
return if count == 0 && size == 0
|
||||||
|
|
||||||
log_entry = opslog_bucket.new
|
log_entry = opslog_bucket.new
|
||||||
log_entry.content_type = "application/json"
|
log_entry.content_type = "application/json"
|
||||||
log_entry.data = {
|
log_entry.data = {
|
||||||
"count" => count,
|
"count" => count,
|
||||||
"size" => (-old_size + new_size),
|
"size" => size,
|
||||||
"category" => extract_category(directory)
|
"category" => extract_category(directory)
|
||||||
}
|
}
|
||||||
log_entry.indexes.merge!({:user_id_bin => [user]})
|
log_entry.indexes.merge!({:user_id_bin => [user]})
|
||||||
|
@ -398,6 +398,22 @@ describe "App with Riak backend" do
|
|||||||
log_entry.indexes["user_id_bin"].must_include "jimmy"
|
log_entry.indexes["user_id_bin"].must_include "jimmy"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "overwriting existing file with same file" do
|
||||||
|
before do
|
||||||
|
header "Content-Type", "image/jpeg; charset=binary"
|
||||||
|
filename = File.join(File.expand_path(File.dirname(__FILE__)), "fixtures", "rockrule.jpeg")
|
||||||
|
@image = File.open(filename, "r").read
|
||||||
|
put "/jimmy/documents/jaypeg", @image
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't log the operation" do
|
||||||
|
objects = []
|
||||||
|
opslog_bucket.keys.each { |k| objects << opslog_bucket.get(k) rescue nil }
|
||||||
|
|
||||||
|
objects.size.must_equal 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "overwriting existing file with different file" do
|
context "overwriting existing file with different file" 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