Skip to content

Commit

Permalink
Merge pull request #545 from stanhu/sh-simplify-file-body
Browse files Browse the repository at this point in the history
Avoid duplicate GET requests when retrieving body
  • Loading branch information
Temikus authored Aug 8, 2021
2 parents 7e39340 + 5dcfd43 commit 8391522
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/fog/storage/google_json/models/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ def predefined_acl=(new_predefined_acl)
end

def body
last_modified && (file = collection.get(identity)) ? attributes[:body] ||= file.body : attributes[:body] ||= ""
return attributes[:body] if attributes.key?(:body)

file = collection.get(identity)

attributes[:body] =
if file
file.attributes[:body]
else
""
end
end

def body=(new_body)
Expand Down

0 comments on commit 8391522

Please sign in to comment.