Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/core/utils.py
Show All 12 Lines | |||||
def clean_dangling_folders(dirpath, pattern_check, log=None): | def clean_dangling_folders(dirpath, pattern_check, log=None): | ||||
"""Clean up potential dangling temporary working folder rooted at | """Clean up potential dangling temporary working folder rooted at | ||||
`dirpath`. Those folders must match a dedicated pattern and not | `dirpath`. Those folders must match a dedicated pattern and not | ||||
belonging to a live pid. | belonging to a live pid. | ||||
Args: | Args: | ||||
dirpath (str): Path to check for dangling files | dirpath (str): Path to check for dangling files | ||||
pattern_check (str): A dedicated pattern to check on first | pattern_check (str): A dedicated pattern to check on first | ||||
level directory (e.g `swh.loader.mercurial.`, | level directory (e.g `swh.loader.mercurial.`, | ||||
`swh.loader.svn.`) | `swh.loader.svn.`) | ||||
log (Logger): Optional logger | log (Logger): Optional logger | ||||
""" | """ | ||||
if not os.path.exists(dirpath): | if not os.path.exists(dirpath): | ||||
return | return | ||||
for filename in os.listdir(dirpath): | for filename in os.listdir(dirpath): | ||||
path_to_cleanup = os.path.join(dirpath, filename) | path_to_cleanup = os.path.join(dirpath, filename) | ||||
try: | try: | ||||
# pattern: `swh.loader.svn-pid.{noise}` | # pattern: `swh.loader.svn-pid.{noise}` | ||||
Show All 17 Lines |