]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Make sure all times are converted to GMT, so we can compare them correctly
authorWido den Hollander <wido@widodh.nl>
Mon, 26 Jul 2010 20:58:26 +0000 (22:58 +0200)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 27 Jul 2010 17:28:47 +0000 (10:28 -0700)
src/rgw/rgw_common.cc
src/rgw/rgw_rados.cc

index bbf6540c14346a0fe08b729bb1020fbb745b078e..4ea8c9f79626f3e323853af9f498f76543146520 100644 (file)
@@ -7,7 +7,7 @@ int parse_time(const char *time_str, time_t *time)
 {
   struct tm tm;
   memset(&tm, 0, sizeof(struct tm));
-  if (!strptime(time_str, "%a, %d %b %Y %H:%M:%S GMT", &tm))
+  if (!strptime(time_str, "%a, %d %b %Y %H:%M:%S %Z", &tm))
     return -EINVAL;
 
   *time = mktime(&tm);
index 0b1b831ee2e2365a37a0a000f1c761af9a123153..baa092beb9a651eb05dc102681494020c98ac09c 100644 (file)
@@ -523,6 +523,7 @@ int RGWRados::prepare_get_obj(std::string& bucket, std::string& oid,
   uint64_t size;
   bufferlist etag;
   time_t mtime;
+  time_t ctime;
 
   map<string, bufferlist>::iterator iter;
 
@@ -551,10 +552,13 @@ int RGWRados::prepare_get_obj(std::string& bucket, std::string& oid,
       goto done_err;
   }
 
+  /* Convert all times go GMT to make them compatible */
+  ctime = mktime(gmtime(&mtime));
 
   r = -ECANCELED;
   if (mod_ptr) {
-    if (mtime < *mod_ptr) {
+    cout << "mod_ptr: " << *mod_ptr << " ctime: " << ctime << endl;
+    if (ctime < *mod_ptr) {
       err->num = "304";
       err->code = "NotModified";
       goto done_err;
@@ -562,7 +566,7 @@ int RGWRados::prepare_get_obj(std::string& bucket, std::string& oid,
   }
 
   if (unmod_ptr) {
-    if (mtime >= *mod_ptr) {
+    if (ctime > *mod_ptr) {
       err->num = "412";
       err->code = "PreconditionFailed";
       goto done_err;