better path handling
This commit is contained in:
@@ -48,15 +48,21 @@ class Backup():
|
|||||||
|
|
||||||
def validatePath(self, path):
|
def validatePath(self, path):
|
||||||
"""Check basic condition for backup directory"""
|
"""Check basic condition for backup directory"""
|
||||||
try:
|
|
||||||
if os.path.isfile(path):
|
if path[-1] != "/":
|
||||||
print("Error, you provided a file instead of a directory!")
|
path += "/"
|
||||||
return False
|
|
||||||
|
try :
|
||||||
|
pathExists = os.path.exists(path)
|
||||||
except:
|
except:
|
||||||
print("Provided path is not recognized...")
|
print("Provided path is not recognized...")
|
||||||
return False
|
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:
|
if not self.isBash:
|
||||||
createDir = input(f"\"{path}\" doesn't exists, would you like to create it ? [Y/n]\n").lower()
|
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
|
self.destinationPath = path
|
||||||
|
|
||||||
if self.destinationPath[-1] != "/":
|
|
||||||
self.destinationPath += "/"
|
|
||||||
|
|
||||||
self.preparePath()
|
self.preparePath()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user