Skip to content

Commit

Permalink
feat (TransformationCleaningAgent): chunk the file removals
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Aug 30, 2023
1 parent c8be7f8 commit 8276ec8
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,20 +386,24 @@ def cleanContent(self, directory):

# Executing with shifter proxy
gConfigurationData.setOptionInCFG("/DIRAC/Security/UseServerCertificate", "false")
res = DataManager().removeFile(filesFound, force=True)
failed = {}
for chunkId, filesChunk in enumerate(breakListIntoChunks(filesFound, 500)):
self.log.info("Removing chunk", chunkId)
res = DataManager().removeFile(filesChunk, force=True)
if not res["OK"]:
failed.update(dict.fromkeys(filesChunk, res["Message"]))
failed.update(res["Value"]["Failed"])
gConfigurationData.setOptionInCFG("/DIRAC/Security/UseServerCertificate", "true")

if not res["OK"]:
return res
realFailure = False
for lfn, reason in res["Value"]["Failed"].items():
for lfn, reason in failed.items():
if "File does not exist" in str(reason):
self.log.warn(f"File {lfn} not found in some catalog: ")
else:
self.log.error("Failed to remove file found in the catalog", f"{lfn} {reason}")
realFailure = True
if realFailure:
return S_ERROR("Failed to remove all files found in the catalog")
return S_ERROR("Failed to remove some files found in the catalog")
return S_OK()

def __getCatalogDirectoryContents(self, directories):
Expand Down

0 comments on commit 8276ec8

Please sign in to comment.