diff --git a/lib/remote_storage/rest_provider.rb b/lib/remote_storage/rest_provider.rb index c394689..621d456 100644 --- a/lib/remote_storage/rest_provider.rb +++ b/lib/remote_storage/rest_provider.rb @@ -289,10 +289,9 @@ module RemoteStorage def metadata_changed?(old_metadata, new_metadata) # check metadata relevant to the directory listing - # ie. the timestamp (m) is not relevant, because it's not used in - # the listing return old_metadata["e"] != new_metadata[:e] || old_metadata["s"] != new_metadata[:s].to_s || + old_metadata["m"] != new_metadata[:m] || old_metadata["t"] != new_metadata[:t] end diff --git a/spec/s3/app_spec.rb b/spec/s3/app_spec.rb index 828c6f8..6c922b2 100644 --- a/spec/s3/app_spec.rb +++ b/spec/s3/app_spec.rb @@ -24,6 +24,14 @@ describe "S3 provider" do stub_request(:put, "#{container_url_for("phil")}/food/aguacate"). with(body: "muy deliciosa"). to_return(status: 200, headers: { etag: '"0815etag"' }) + stub_request(:put, "#{container_url_for("phil")}/food/banano"). + with(body: "si"). + to_return(status: 200, headers: { etag: '"0815etag"' }) + stub_request(:put, "#{container_url_for("phil")}/food/banano"). + with(body: "oh, no"). + to_return(status: 200, headers: { etag: '"0817etag"' }) + stub_request(:head, "#{container_url_for("phil")}/food/banano"). + to_return(status: 200, headers: { last_modified: "Fri, 04 Mar 2016 12:20:20 GMT" }) stub_request(:head, "#{container_url_for("phil")}/food/aguacate"). to_return(status: 200, headers: { last_modified: "Fri, 04 Mar 2016 12:20:18 GMT" }) stub_request(:delete, "#{container_url_for("phil")}/food/aguacate"). diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb index baa6900..fd5f742 100644 --- a/spec/shared_examples.rb +++ b/spec/shared_examples.rb @@ -38,6 +38,17 @@ shared_examples_for 'a REST adapter' do metadata["m"].length.must_equal 13 end + it "updates the metadata object in redis when it changes" do + put "/phil/food/banano", "si" + put "/phil/food/banano", "oh, no" + + metadata = redis.hgetall "rs:m:phil:food/banano" + metadata["s"].must_equal "6" + metadata["t"].must_equal "text/plain; charset=utf-8" + metadata["e"].must_equal "0817etag" + metadata["m"].must_equal "1457094020000" + end + it "creates the directory objects metadata in redis" do put "/phil/food/aguacate", "si" put "/phil/food/camaron", "yummi" diff --git a/spec/swift/app_spec.rb b/spec/swift/app_spec.rb index 41884f3..2bc913d 100644 --- a/spec/swift/app_spec.rb +++ b/spec/swift/app_spec.rb @@ -24,6 +24,12 @@ describe "Swift provider" do stub_request(:put, "#{container_url_for("phil")}/food/aguacate"). with(body: "muy deliciosa"). to_return(status: 200, headers: { etag: "0815etag", last_modified: "Fri, 04 Mar 2016 12:20:18 GMT" }) + stub_request(:put, "#{container_url_for("phil")}/food/banano"). + with(body: "si"). + to_return(status: 200, headers: { etag: "0815etag", last_modified: "Fri, 04 Mar 2016 12:20:18 GMT" }) + stub_request(:put, "#{container_url_for("phil")}/food/banano"). + with(body: "oh, no"). + to_return(status: 200, headers: { etag: "0817etag", last_modified: "Fri, 04 Mar 2016 12:20:20 GMT" }) stub_request(:head, "#{container_url_for("phil")}/food/aguacate"). to_return(status: 200, headers: { last_modified: "Fri, 04 Mar 2016 12:20:18 GMT" }) stub_request(:delete, "#{container_url_for("phil")}/food/aguacate").