MCPcopy
hub / github.com/ArchiveBox/ArchiveBox / chmod_file

Function chmod_file

archivebox/system.py:112–128  ·  view source on GitHub ↗

chmod -R /

(path: str, cwd: str='.')

Source from the content-addressed store, hash-verified

110
111@enforce_types
112def chmod_file(path: str, cwd: str='.') -> None:
113 """chmod -R <permissions> <cwd>/<path>"""
114
115 root = Path(cwd) / path
116 if not root.exists():
117 raise Exception('Failed to chmod: {} does not exist (did the previous step fail?)'.format(path))
118
119 if not root.is_dir():
120 # path is just a plain file
121 os.chmod(root, int(OUTPUT_PERMISSIONS, base=8))
122 else:
123 for subpath in Path(path).glob('**/*'):
124 if subpath.is_dir():
125 # directories need execute permissions to be able to list contents
126 os.chmod(subpath, int(DIR_OUTPUT_PERMISSIONS, base=8))
127 else:
128 os.chmod(subpath, int(OUTPUT_PERMISSIONS, base=8))
129
130
131@enforce_types

Callers 9

save_faviconFunction · 0.85
save_singlefileFunction · 0.85
save_pdfFunction · 0.85
save_domFunction · 0.85
save_mediaFunction · 0.85
save_screenshotFunction · 0.85
save_wgetFunction · 0.85
save_gitFunction · 0.85
save_archive_dot_orgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected