Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/checker/checker.py
| Show All 28 Lines | class ContentChecker(): | ||||
| Attributes: | Attributes: | ||||
| config: dictionary that contains this | config: dictionary that contains this | ||||
| checker configuration | checker configuration | ||||
| objstorage (ObjStorage): Local object storage that will be checked. | objstorage (ObjStorage): Local object storage that will be checked. | ||||
| master_storage (RemoteStorage): A distant storage that will be used to | master_storage (RemoteStorage): A distant storage that will be used to | ||||
| restore corrupted content. | restore corrupted content. | ||||
| """ | """ | ||||
| def __init__(self, config, root, depth, backup_urls): | def __init__(self, config, root, slicing, backup_urls): | ||||
| """ Create a checker that ensure the objstorage have no corrupted file. | """ Create a checker that ensure the objstorage have no corrupted file. | ||||
| Args: | Args: | ||||
| config (dict): Dictionary that contains the following keys : | config (dict): Dictionary that contains the following keys : | ||||
| batch_size: Number of content that should be tested each | batch_size: Number of content that should be tested each | ||||
| time the content checker runs. | time the content checker runs. | ||||
| root (string): Path to the objstorage directory | root (string): Path to the objstorage directory | ||||
| depth (int): Depth of the object storage. | depth (int): Depth of the object storage. | ||||
| backup_urls: List of url that can be contacted in order to | backup_urls: List of url that can be contacted in order to | ||||
| get a content. | get a content. | ||||
| """ | """ | ||||
| self.config = config | self.config = config | ||||
| self.objstorage = PathSlicingObjStorage(root, depth, slicing=2) | self.objstorage = PathSlicingObjStorage(root, slicing) | ||||
| self.backup_storages = [get_storage('remote_storage', [backup_url]) | self.backup_storages = [get_storage('remote_storage', [backup_url]) | ||||
| for backup_url in backup_urls] | for backup_url in backup_urls] | ||||
| def run(self): | def run(self): | ||||
| """ Start the check routine | """ Start the check routine | ||||
| """ | """ | ||||
| corrupted_contents = [] | corrupted_contents = [] | ||||
| batch_size = self.config['batch_size'] | batch_size = self.config['batch_size'] | ||||
| ▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines | |||||