diff --git a/maya_umbrella/cleaner.py b/maya_umbrella/cleaner.py index 5f340ea..f2c1ce2 100644 --- a/maya_umbrella/cleaner.py +++ b/maya_umbrella/cleaner.py @@ -22,6 +22,7 @@ class MayaVirusCleaner(object): translator (Translator): Translator object for translation purposes. collector (MayaVirusCollector): MayaVirusCollector object for collecting issues. """ + def __init__(self, collector, logger=None): """Initialize the MayaVirusCleaner. @@ -50,6 +51,9 @@ def fix_script_jobs(self): def fix_malicious_files(self): """Fix malicious files.""" for file_ in self.collector.malicious_files: + if not os.access(file_, os.W_OK): + self.logger.debug(self.translator.translate("file_not_writable", name=file_)) + continue if os.path.exists(file_): if os.path.isfile(file_): self.logger.debug(self.translator.translate("remove_file", name=file_)) @@ -94,6 +98,9 @@ def fix_infected_files(self): """Fix infected files.""" for file_path in self.collector.infected_files: self.logger.info(self.translator.translate("fix_infected_files", name=file_path)) + if not os.access(file_path, os.W_OK): + self.logger.debug(self.translator.translate("file_not_writable", name=file_path)) + continue remove_virus_file_by_signature(file_path, FILE_VIRUS_SIGNATURES) self.collector.remove_infected_file(file_path) diff --git a/maya_umbrella/locales/en_US.json b/maya_umbrella/locales/en_US.json index 078ecdd..b885c15 100644 --- a/maya_umbrella/locales/en_US.json +++ b/maya_umbrella/locales/en_US.json @@ -15,5 +15,6 @@ "delete": "Deleting: $name", "remove_file": "Deleting file:$name", "remove_path": "Deleting path:$name", - "fix_script_job": "Kill script job: %s" + "fix_script_job": "Kill script job: %s", + "file_not_writable": "File not writable: $name" } diff --git a/maya_umbrella/locales/zh_CN.json b/maya_umbrella/locales/zh_CN.json index 4c7be15..3107a17 100644 --- a/maya_umbrella/locales/zh_CN.json +++ b/maya_umbrella/locales/zh_CN.json @@ -15,5 +15,6 @@ "delete": "删除感染文件:$name", "remove_file": "删除文件:$name", "remove_path": "删除文件夹:$name", - "fix_script_job": "删除被感染的节点:$name" + "fix_script_job": "删除被感染的节点:$name", + "file_not_writable": "文件不可写:$name" }