Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/multiplexer/multiplexer_objstorage.py
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | def check(self, obj_id): | ||||
nb_present += 1 | nb_present += 1 | ||||
# If there is an Error because of a corrupted file, then let it pass. | # If there is an Error because of a corrupted file, then let it pass. | ||||
# Raise the ObjNotFoundError only if the content coulnd't be found in | # Raise the ObjNotFoundError only if the content coulnd't be found in | ||||
# all the storages. | # all the storages. | ||||
if nb_present == 0: | if nb_present == 0: | ||||
raise ObjNotFoundError(obj_id) | raise ObjNotFoundError(obj_id) | ||||
def delete(self, obj_id): | |||||
return all(storage.delete(obj_id) for storage in self.storages) | |||||
def get_random(self, batch_size): | def get_random(self, batch_size): | ||||
storages_set = [storage for storage in self.storages | storages_set = [storage for storage in self.storages | ||||
if len(storage) > 0] | if len(storage) > 0] | ||||
if len(storages_set) <= 0: | if len(storages_set) <= 0: | ||||
return [] | return [] | ||||
while storages_set: | while storages_set: | ||||
storage = random.choice(storages_set) | storage = random.choice(storages_set) | ||||
Show All 9 Lines |