Commit a690e49c authored by Sofia Papagiannaki's avatar Sofia Papagiannaki Committed by Chrysostomos Nanakos
Browse files

pithos: Handle properly zero size objects

The backend should not store zero size objects.
This commit contains the necessary modifications for the modular backend.
parent 13d49ad6
......@@ -354,6 +354,11 @@ class ModularBackend(BaseBackend):
def empty_string_hash(self):
return binascii.hexlify(HashMap(self.block_size,
def pre_exec(self, lock_container_path=False):
self.lock_container_path = lock_container_path
......@@ -1173,14 +1178,17 @@ class ModularBackend(BaseBackend):
self._can_read_object(user, account, container, name)
path, node = self._lookup_object(account, container, name)
props = self._get_version(node, version)
props = self._get_version(node, version, keys=_propnames)
if props[self.HASH] is None:
return 0, ()
return 0, []
if props[self.HASH].startswith('archip:'):
hashmap = self._update_available(props)
return props[self.SIZE], [x for x in hashmap]
hashmap =[self.HASH], props[self.SIZE])
size = props[self.SIZE]
if size == 0:
return 0, [self.empty_string_hash]
hashmap =[self.MAPFILE], props[self.SIZE])
return props[self.SIZE], [x for x in hashmap]
def _update_object_hash(self, user, account, container, name, size, type,
......@@ -1342,7 +1350,8 @@ class ModularBackend(BaseBackend):
dest_version_id, _, mapfile = self._update_object_hash(
user, account, container, name, size, type, hexlified, checksum,
domain, meta, replace_meta, permissions, is_snapshot=False), map_, size, self.block_size)
if size != 0:, map_, size, self.block_size)
return dest_version_id, hexlified
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment