diff --git a/image_creator/os_type/__init__.py b/image_creator/os_type/__init__.py index 19e63fc520bef1164fa90702a7b758c747842ff5..529856996516defa28dd9f4e5f9cdd5a07ac0e0a 100644 --- a/image_creator/os_type/__init__.py +++ b/image_creator/os_type/__init__.py @@ -320,6 +320,10 @@ class OSBase(object): * 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'] if maxdepth == 0: return diff --git a/image_creator/os_type/unix.py b/image_creator/os_type/unix.py index 8779b76632e5ab9b0d4db06297c5bada9c57fb9d..7255f444c7b2f11c6a1b027756c539e2eab9f2e8 100644 --- a/image_creator/os_type/unix.py +++ b/image_creator/os_type/unix.py @@ -108,9 +108,7 @@ class Unix(OSBase): def cleanup_mail(self): """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)