mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 02:26:53 -07:00
Refactor path functions from utils to utils.paths
This commit is contained in:
parent
36932e25c6
commit
e44c0bb56a
2 changed files with 37 additions and 32 deletions
|
@ -125,3 +125,27 @@ def flatten_dir(destination, files):
|
|||
logger.error('Could not flatten {0}'.format(outputFile), 'FLATTEN')
|
||||
|
||||
remove_empty_folders(destination) # Cleanup empty directories
|
||||
|
||||
|
||||
def clean_directory(path, files):
|
||||
if not os.path.exists(path):
|
||||
logger.info('Directory {0} has been processed and removed ...'.format(path), 'CLEANDIR')
|
||||
return
|
||||
|
||||
if core.FORCE_CLEAN and not core.FAILED:
|
||||
logger.info('Doing Forceful Clean of {0}'.format(path), 'CLEANDIR')
|
||||
remove_dir(path)
|
||||
return
|
||||
|
||||
if files:
|
||||
logger.info(
|
||||
'Directory {0} still contains {1} unprocessed file(s), skipping ...'.format(path, len(files)),
|
||||
'CLEANDIRS',
|
||||
)
|
||||
return
|
||||
|
||||
logger.info('Directory {0} has been processed, removing ...'.format(path), 'CLEANDIRS')
|
||||
try:
|
||||
shutil.rmtree(path, onerror=onerror)
|
||||
except Exception:
|
||||
logger.error('Unable to delete directory {0}'.format(path))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue