Add error ignoring when using the rmtree function

This commit is contained in:
Théophile Diot 2023-05-22 12:49:44 -04:00
parent 0b082bdab7
commit f84af34025
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
3 changed files with 7 additions and 7 deletions

View File

@ -122,7 +122,7 @@ try:
path = f"/etc/bunkerweb/plugins/{plugin}"
if not Path(f"{path}/plugin.json").is_file():
logger.warning(f"Plugin {plugin} is not valid, deleting it...")
rmtree(path)
rmtree(path, ignore_errors=True)
continue
plugin_file = loads(Path(f"{path}/plugin.json").read_text())
@ -169,6 +169,6 @@ except:
logger.error(f"Exception while running download-plugins.py :\n{format_exc()}")
for plugin_tmp in glob("/var/tmp/bunkerweb/plugins-*/"):
rmtree(plugin_tmp)
rmtree(plugin_tmp, ignore_errors=True)
sys_exit(status)

View File

@ -344,7 +344,7 @@ if __name__ == "__main__":
if Path(file).is_symlink() or Path(file).is_file():
Path(file).unlink()
elif Path(file).is_dir():
rmtree(file, ignore_errors=False)
rmtree(file, ignore_errors=True)
generate_external_plugins(
db.get_plugins(external=True, with_data=True),
@ -504,7 +504,7 @@ if __name__ == "__main__":
if Path(file).is_symlink() or Path(file).is_file():
Path(file).unlink()
elif Path(file).is_dir():
rmtree(file, ignore_errors=False)
rmtree(file, ignore_errors=True)
logger.info("Generating new custom configs ...")
generate_custom_configs(custom_configs, integration, api_caller)
@ -548,7 +548,7 @@ if __name__ == "__main__":
if Path(file).is_symlink() or Path(file).is_file():
Path(file).unlink()
elif Path(file).is_dir():
rmtree(file, ignore_errors=False)
rmtree(file, ignore_errors=True)
logger.info("Generating new external plugins ...")
generate_external_plugins(

View File

@ -45,7 +45,7 @@ class ConfigFiles:
if Path(file).is_symlink() or Path(file).is_file():
Path(file).unlink()
elif Path(file).is_dir():
rmtree(file, ignore_errors=False)
rmtree(file, ignore_errors=True)
generate_custom_configs(custom_configs)
self.__logger.info("Custom configs refreshed successfully")
@ -118,7 +118,7 @@ class ConfigFiles:
if Path(path).is_file() or Path(f"{path}.conf").is_file():
Path(f"{path}.conf").unlink()
else:
rmtree(path)
rmtree(path, ignore_errors=True)
except OSError:
return f"Could not delete {path}", 1