storage: store hashed_index with strings (#6222)
This commit is contained in:
parent
5178ee8b4e
commit
65c684dec6
|
@ -409,7 +409,7 @@ class StorableObject(object):
|
|||
index_name = '%s-%s' % (index, attr_value)
|
||||
if not index_name in hashed_indexes:
|
||||
hashed_indexes[index_name] = []
|
||||
hashed_indexes[index_name].append(object.id)
|
||||
hashed_indexes[index_name].append(str(object.id))
|
||||
|
||||
for index, content in hashed_indexes.items():
|
||||
index_key = index.split('-')[0]
|
||||
|
@ -594,9 +594,9 @@ class StorableObject(object):
|
|||
old_index_name = '%s-%s' % (index, fix_key(oldv))
|
||||
old_index_file = os.path.join(index_dir, old_index_name)
|
||||
if os.path.exists(old_index_file):
|
||||
ids = pickle.load(file(old_index_file))
|
||||
if self.id in ids:
|
||||
ids.remove(self.id)
|
||||
ids = [str(x) for x in pickle.load(file(old_index_file))]
|
||||
if str(self.id) in ids:
|
||||
ids.remove(str(self.id))
|
||||
pickle.dump(ids, file(old_index_file, 'w'))
|
||||
|
||||
for newv in new_value:
|
||||
|
@ -605,11 +605,11 @@ class StorableObject(object):
|
|||
index_name = '%s-%s' % (index, fix_key(newv))
|
||||
index_file = os.path.join(index_dir, index_name)
|
||||
if os.path.exists(index_file):
|
||||
ids = pickle.load(file(index_file))
|
||||
ids = [str(x) for x in pickle.load(file(index_file))]
|
||||
else:
|
||||
ids = []
|
||||
if not self.id in ids:
|
||||
ids.append(self.id)
|
||||
if not str(self.id) in ids:
|
||||
ids.append(str(self.id))
|
||||
pickle.dump(ids, file(index_file, 'w'))
|
||||
|
||||
|
||||
|
@ -644,9 +644,9 @@ class StorableObject(object):
|
|||
index_name = '%s-%s' % (index, attr_value)
|
||||
index_file = os.path.join(index_dir, index, index_name)
|
||||
if os.path.exists(index_file):
|
||||
ids = pickle.load(file(index_file))
|
||||
if object.id in ids:
|
||||
ids.remove(object.id)
|
||||
ids = [str(x) for x in pickle.load(file(index_file))]
|
||||
if str(object.id) in ids:
|
||||
ids.remove(str(object.id))
|
||||
pickle.dump(ids, file(index_file, 'w'))
|
||||
|
||||
os.unlink(os.path.join(objects_dir, fix_key(id)))
|
||||
|
|
Loading…
Reference in New Issue