]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: implement object_is_expired function.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 13 May 2015 14:35:51 +0000 (16:35 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 27 Aug 2015 18:51:03 +0000 (11:51 -0700)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Conflicts:
src/rgw/rgw_op.cc

src/rgw/rgw_op.cc

index 5aafe137938af750652d8715e740cec8e3476137..0c76f1581bb6bfc8b77d1e16d83a3e441ef0df5b 100644 (file)
@@ -911,6 +911,25 @@ void RGWGetObj::pre_exec()
   rgw_bucket_object_pre_exec(s);
 }
 
+static bool object_is_expired(map<string, bufferlist>& attrs) {
+  map<string, bufferlist>::iterator iter = attrs.find(RGW_ATTR_DELETE_AT);
+  if (iter != attrs.end()) {
+    utime_t delete_at;
+    try {
+      ::decode(delete_at, iter->second);
+    } catch (buffer::error& err) {
+      dout(0) << "ERROR: " << __func__ << ": failed to decode " RGW_ATTR_DELETE_AT " attr" << dendl;
+      return false;
+    }
+
+    if (delete_at <= ceph_clock_now(g_ceph_context)) {
+      return true;
+    }
+  }
+
+  return false;
+}
+
 void RGWGetObj::execute()
 {
   utime_t start_time = s->time;
@@ -964,21 +983,9 @@ void RGWGetObj::execute()
 
   /* Check whether the object has expired. Swift API documentation
    * stands that we should return 404 Not Found in such case. */
-  attr_iter = attrs.find(RGW_ATTR_DELETE_AT);
-  if (need_object_expiration() && attr_iter != attrs.end()) {
-    utime_t delete_at;
-    try {
-      ::decode(delete_at, attr_iter->second);
-    } catch (buffer::error& err) {
-      ret = -EIO;
-      ldout(s->cct, 0) << "ERROR: failed to decode " RGW_ATTR_DELETE_AT " attribute" << dendl;
-      goto done_err;
-    }
-
-    if (delete_at <= ceph_clock_now(g_ceph_context)) {
-      ret = -ENOENT;
-      goto done_err;
-    }
+  if (need_object_expiration() && object_is_expired(attrs)) {
+    ret = -ENOENT;
+    goto done_err;
   }
 
   ofs = new_ofs;