storage: fix handling of multiple indexes (#...)

This commit is contained in:
Frédéric Péters 2017-07-19 20:40:27 +02:00
parent 53cf3e1b15
commit f7381f59ba
1 changed files with 5 additions and 5 deletions

View File

@ -564,7 +564,7 @@ class StorableObject(object):
def update_indexes(self, previous_object_value, relative_object_filename):
objects_dir = self.get_objects_dir()
rebuilt_indexes = False
rebuilt_indexes = []
for index in self._indexes or []:
if not hasattr(self, index) or getattr(self, index) is None:
continue
@ -588,16 +588,16 @@ class StorableObject(object):
except OSError, exc:
if exc.errno == 2:
os.mkdir(index_dir)
if not rebuilt_indexes:
if not index in rebuilt_indexes:
# perhaps index dir got removed; rebuild it before
# adding elements to it.
self.rebuild_indexes()
rebuilt_indexes = True
self.rebuild_indexes(indexes=[index])
rebuilt_indexes.append(index)
elif exc.errno == 17:
os.unlink(link_name)
else:
raise
if not rebuilt_indexes:
if not index in rebuilt_indexes:
if relative_object_filename:
os.symlink(relative_object_filename, link_name)
else: