Story #5613

Updated by bmbouter over 4 years ago

## Motivation 

 Users can experience corrupted files either due to bit rot on mechanical hard drives or mistakenly run commands. We should make it as easy as possible to correct this situation when we can. 

 ## Idea 

 Make a new API endpoint I imagine some task that lives at `/pulp/api/v3/repair/` and has 1 required parameter `repository` which is the href to the repository that is being requested to be repaired. Initially every request will be for a single repository. given repo: 

 ## Details 

 1\. examines all downloaded content in the latest version and checks to see if each unit matches its expected checksum   
 2\. re-downloads any corrupted files if possible based on RemoteArtifact entries in db 
 3\. reports any units that could not be re-downloaded as counts 

 ## API Response 

     "pulp_created": "2019-07-23T08:18:12.927007Z", 
     "pulp_href": "/pulp/api/v3/task-groups/59f8a786-c7d7-4e2b-ad07-701479d403c5/", 
     "repository_version_href": "/pulp/api/v3/repository/<path to the repository version/", 
     "checked": 7264, 
     "repaired": 3, 
     "unrepairable": 0, 

 The checked count is expected to equal the count of total items in the repository version. 

 ## Note 

 This Note: this is only going to fix bitrot/corrupted files. It only inspects the content contained in the latest repository version, and does not consider if that repository version is an accurate or complete representation of the remote filesystem.