Skip to content
Snippets Groups Projects
Commit a38447ba authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

In _foreach_file check if the directory exists

Otherwise print a warning.
parent 6a7a5d4e
No related branches found
No related tags found
No related merge requests found
...@@ -320,6 +320,10 @@ class OSBase(object): ...@@ -320,6 +320,10 @@ class OSBase(object):
* exclude: Exclude all files that follow this pattern. * exclude: Exclude all files that follow this pattern.
""" """
if not self.image.g.is_dir(directory):
self.out.warn("Directory: `%s' does not exist!" % directory)
return
maxdepth = None if 'maxdepth' not in kargs else kargs['maxdepth'] maxdepth = None if 'maxdepth' not in kargs else kargs['maxdepth']
if maxdepth == 0: if maxdepth == 0:
return return
......
...@@ -108,9 +108,7 @@ class Unix(OSBase): ...@@ -108,9 +108,7 @@ class Unix(OSBase):
def cleanup_mail(self): def cleanup_mail(self):
"""Remove all files under /var/mail and /var/spool/mail""" """Remove all files under /var/mail and /var/spool/mail"""
if self.image.g.is_dir('/var/spool/mail'): self._foreach_file('/var/spool/mail', self.image.g.rm_rf, maxdepth=1)
self._foreach_file('/var/spool/mail', self.image.g.rm_rf,
maxdepth=1)
self._foreach_file('/var/mail', self.image.g.rm_rf, maxdepth=1) self._foreach_file('/var/mail', self.image.g.rm_rf, maxdepth=1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment