mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 18:47:09 -07:00
Refactor rchmod to utils.paths.rchmod
This commit is contained in:
parent
aa057e65d5
commit
d960c432eb
3 changed files with 35 additions and 17 deletions
|
@ -37,6 +37,7 @@ from core.utils.paths import (
|
|||
get_dir_size,
|
||||
make_dir,
|
||||
onerror,
|
||||
rchmod,
|
||||
remote_dir,
|
||||
remove_dir,
|
||||
remove_empty_folders,
|
||||
|
|
|
@ -149,3 +149,16 @@ def clean_directory(path, files):
|
|||
shutil.rmtree(path, onerror=onerror)
|
||||
except Exception:
|
||||
logger.error('Unable to delete directory {0}'.format(path))
|
||||
|
||||
|
||||
def rchmod(path, mod):
|
||||
logger.log('Changing file mode of {0} to {1}'.format(path, oct(mod)))
|
||||
os.chmod(path, mod)
|
||||
if not os.path.isdir(path):
|
||||
return # Skip files
|
||||
|
||||
for root, dirs, files in os.walk(path):
|
||||
for d in dirs:
|
||||
os.chmod(os.path.join(root, d), mod)
|
||||
for f in files:
|
||||
os.chmod(os.path.join(root, f), mod)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue