Also use content checksum for ETag calculation
Timestamp is not enough, as it might be the same for two consequent PUTs.
This commit is contained in:
@@ -156,7 +156,7 @@ module RemoteStorage
|
||||
|
||||
if update_metadata_object(user, directory, key, metadata)
|
||||
if metadata_changed?(existing_metadata, metadata)
|
||||
update_dir_objects(user, directory, timestamp)
|
||||
update_dir_objects(user, directory, timestamp, checksum_for(data))
|
||||
end
|
||||
|
||||
server.headers["ETag"] = %Q("#{res.headers[:etag]}")
|
||||
@@ -166,6 +166,10 @@ module RemoteStorage
|
||||
end
|
||||
end
|
||||
|
||||
def checksum_for(data)
|
||||
Digest::MD5.hexdigest(data)
|
||||
end
|
||||
|
||||
def delete_data(user, directory, key)
|
||||
url = url_for_key(user, directory, key)
|
||||
|
||||
@@ -316,9 +320,9 @@ module RemoteStorage
|
||||
true
|
||||
end
|
||||
|
||||
def update_dir_objects(user, directory, timestamp)
|
||||
def update_dir_objects(user, directory, timestamp, checksum)
|
||||
parent_directories_for(directory).each do |dir|
|
||||
etag = etag_for(dir, timestamp)
|
||||
etag = etag_for(dir, timestamp, checksum)
|
||||
|
||||
key = "rs:m:#{user}:#{dir}/"
|
||||
metadata = {e: etag, m: timestamp}
|
||||
|
||||
Reference in New Issue
Block a user