Fix manifest and copy/move prefix parsing.
authorAntony Chazapis <chazapis@gmail.com>
Tue, 14 Jun 2011 20:00:42 +0000 (23:00 +0300)
committerAntony Chazapis <chazapis@gmail.com>
Tue, 14 Jun 2011 20:00:42 +0000 (23:00 +0300)
docs/source/devguide.rst
pithos/api/functions.py
pithos/api/util.py
pithos/backends/simple.py
pithos/public/functions.py

index 27adf38..ff48bcb 100644 (file)
@@ -294,7 +294,7 @@ content-disposition         The presentation style of the object (optional)
 last_modified               The last object modification date (regardless of version)
 x_object_version            The object's version identifier
 x_object_version_timestamp  The object's version timestamp
-x_object_manifest           Large object support (optional)
+x_object_manifest           Object parts prefix in ``<container>/<object>`` form (optional)
 x_object_public             Object is publicly accessible (optional)
 x_object_meta_*             Optional user defined metadata
 ==========================  ======================================
@@ -412,7 +412,7 @@ Content-Encoding            The encoding of the object (optional)
 Content-Disposition         The presentation style of the object (optional)
 X-Object-Version            The object's version identifier
 X-Object-Version-Timestamp  The object's version timestamp
-X-Object-Manifest           Large object support (optional)
+X-Object-Manifest           Object parts prefix in ``<container>/<object>`` form (optional)
 X-Object-Public             Object is publicly accessible (optional)
 X-Object-Meta-*             Optional user defined metadata
 ==========================  ===============================
@@ -501,7 +501,7 @@ Content-Encoding            The encoding of the object (optional)
 Content-Disposition         The presentation style of the object (optional)
 X-Object-Version            The object's version identifier
 X-Object-Version-Timestamp  The object's version timestamp
-X-Object-Manifest           Large object support (optional)
+X-Object-Manifest           Object parts prefix in ``<container>/<object>`` form (optional)
 X-Object-Public             Object is publicly accessible (optional)
 X-Object-Meta-*             Optional user defined metadata
 ==========================  ===============================
@@ -534,7 +534,7 @@ X-Move-From           The source path in the form ``/<container>/<object>``
 X-Source-Version      The source version to copy/move from
 Content-Encoding      The encoding of the object (optional)
 Content-Disposition   The presentation style of the object (optional)
-X-Object-Manifest     Large object support (optional)
+X-Object-Manifest     Object parts prefix in ``<container>/<object>`` form (optional)
 X-Object-Public       Object is publicly accessible (optional)
 X-Object-Meta-*       Optional user defined metadata
 ====================  ================================
@@ -569,7 +569,7 @@ Content-Type          The MIME content type of the object (optional)
 Content-Encoding      The encoding of the object (optional)
 Content-Disposition   The presentation style of the object (optional)
 X-Source-Version      The source version to copy/move from
-X-Object-Manifest     Large object support (optional)
+X-Object-Manifest     Object parts prefix in ``<container>/<object>`` form (optional)
 X-Object-Public       Object is publicly accessible (optional)
 X-Object-Meta-*       Optional user defined metadata
 ====================  ================================
@@ -601,7 +601,7 @@ Content-Range         The range of data supplied (optional, to update)
 Transfer-Encoding     Set to ``chunked`` to specify incremental uploading (if used, ``Content-Length`` is ignored)
 Content-Encoding      The encoding of the object (optional)
 Content-Disposition   The presentation style of the object (optional)
-X-Object-Manifest     Large object support (optional)
+X-Object-Manifest     Object parts prefix in ``<container>/<object>`` form (optional)
 X-Object-Public       Object is publicly accessible (optional)
 X-Object-Meta-*       Optional user defined metadata
 ====================  ================================
index 862f208..b0f5a2f 100644 (file)
@@ -432,7 +432,7 @@ def object_read(request, v_account, v_container, v_object):
     hashmaps = []
     if 'X-Object-Manifest' in meta:
         try:
-            src_container, src_name = split_container_object_string(meta['X-Object-Manifest'])
+            src_container, src_name = split_container_object_string('/' + meta['X-Object-Manifest'])
             objects = backend.list_objects(request.user, v_account, src_container, prefix=src_name, virtual=False)
         except ValueError:
             raise BadRequest('Invalid X-Object-Manifest header')
index 93f3c1e..f41e36c 100644 (file)
@@ -160,7 +160,7 @@ def update_manifest_meta(request, v_account, meta):
         hash = ''
         bytes = 0
         try:
-            src_container, src_name = split_container_object_string(meta['X-Object-Manifest'])
+            src_container, src_name = split_container_object_string('/' + meta['X-Object-Manifest'])
             objects = backend.list_objects(request.user, v_account, src_container, prefix=src_name, virtual=False)
             for x in objects:
                 src_meta = backend.get_object_meta(request.user, v_account, src_container, x[0], x[1])
@@ -209,6 +209,9 @@ def validate_matching_preconditions(request, meta):
             raise NotModified('Resource Etag matches')
 
 def split_container_object_string(s):
+    if not len(s) > 0 or s[0] != '/':
+        raise ValueError
+    s = s[1:]
     pos = s.find('/')
     if pos == -1:
         raise ValueError
index 7f15221..e1ff13c 100644 (file)
@@ -259,6 +259,7 @@ class SimpleBackend(BaseBackend):
         """Copy an object's data and metadata."""
         
         logger.debug("copy_object: %s %s %s %s %s %s %s %s", account, src_container, src_name, dest_container, dest_name, dest_meta, replace_meta, src_version)
+        self._get_containerinfo(account, src_container)
         if src_version is None:
             src_path = self._get_objectinfo(account, src_container, src_name)[0]
         else:
index fb5242e..983612a 100644 (file)
@@ -109,7 +109,7 @@ def object_read(request, v_account, v_container, v_object):
     hashmaps = []
     if 'X-Object-Manifest' in meta:
         try:
-            src_container, src_name = split_container_object_string(meta['X-Object-Manifest'])
+            src_container, src_name = split_container_object_string('/' + meta['X-Object-Manifest'])
             objects = backend.list_objects(request.user, v_account, src_container, prefix=src_name, virtual=False)
         except ValueError:
             raise ItemNotFound('Object does not exist')