diff --git a/modoboa_installer/scripts/backup.py b/modoboa_installer/scripts/backup.py index dc9cabb..52a8329 100644 --- a/modoboa_installer/scripts/backup.py +++ b/modoboa_installer/scripts/backup.py @@ -48,15 +48,21 @@ class Backup(): def validatePath(self, path): """Check basic condition for backup directory""" - try: - if os.path.isfile(path): - print("Error, you provided a file instead of a directory!") - return False + + if path[-1] != "/": + path += "/" + + try : + pathExists = os.path.exists(path) except: print("Provided path is not recognized...") return False + + if pathExists and os.path.isfile(path): + print("Error, you provided a file instead of a directory!") + return False - if not os.path.exists(path): + if not pathExists: if not self.isBash: createDir = input(f"\"{path}\" doesn't exists, would you like to create it ? [Y/n]\n").lower() @@ -76,9 +82,6 @@ class Backup(): self.destinationPath = path - if self.destinationPath[-1] != "/": - self.destinationPath += "/" - self.preparePath() return True