+3
-3
@@ -424,7 +424,7 @@ class Config:
|
|||||||
## Backup
|
## Backup
|
||||||
cnfSec = "Backup"
|
cnfSec = "Backup"
|
||||||
self.backupPath = self._parseLine(
|
self.backupPath = self._parseLine(
|
||||||
cnfParse, cnfSec, "backuppath", self.CNF_STR, self.backupPath
|
cnfParse, cnfSec, "backuppath", self.CNF_STR, self.backupPath
|
||||||
)
|
)
|
||||||
self.backupOnClose = self._parseLine(
|
self.backupOnClose = self._parseLine(
|
||||||
cnfParse, cnfSec, "backuponclose", self.CNF_BOOL, self.backupOnClose
|
cnfParse, cnfSec, "backuponclose", self.CNF_BOOL, self.backupOnClose
|
||||||
@@ -639,7 +639,7 @@ class Config:
|
|||||||
if newPath is None:
|
if newPath is None:
|
||||||
return True
|
return True
|
||||||
if not path.isfile(newPath):
|
if not path.isfile(newPath):
|
||||||
logger.error("Config: File not found. Using default config path instead.")
|
logger.error("File not found, using default config path instead")
|
||||||
return False
|
return False
|
||||||
self.confPath = path.dirname(newPath)
|
self.confPath = path.dirname(newPath)
|
||||||
self.confFile = path.basename(newPath)
|
self.confFile = path.basename(newPath)
|
||||||
@@ -649,7 +649,7 @@ class Config:
|
|||||||
if newPath is None:
|
if newPath is None:
|
||||||
return True
|
return True
|
||||||
if not path.isdir(newPath):
|
if not path.isdir(newPath):
|
||||||
logger.error("Config: Path not found. Using default data path instead.")
|
logger.error("Path not found, using default data path instead")
|
||||||
return False
|
return False
|
||||||
self.dataPath = path.abspath(newPath)
|
self.dataPath = path.abspath(newPath)
|
||||||
return True
|
return True
|
||||||
|
|||||||
+14
-6
@@ -526,25 +526,25 @@ class NWProject():
|
|||||||
self.theParent.makeAlert((
|
self.theParent.makeAlert((
|
||||||
"Cannot backup project because no backup path is set. "
|
"Cannot backup project because no backup path is set. "
|
||||||
"Please set a valid backup location in Tools > Preferences."
|
"Please set a valid backup location in Tools > Preferences."
|
||||||
), nwAlert.WARN)
|
), nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.projName is None or self.projName == "":
|
if self.projName is None or self.projName == "":
|
||||||
self.theParent.makeAlert((
|
self.theParent.makeAlert((
|
||||||
"Cannot backup project because no project name is set. "
|
"Cannot backup project because no project name is set. "
|
||||||
"Please set a Working Title in Project > Project Settings."
|
"Please set a Working Title in Project > Project Settings."
|
||||||
), nwAlert.WARN)
|
), nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not path.isdir(self.mainConf.backupPath):
|
if not path.isdir(self.mainConf.backupPath):
|
||||||
self.theParent.makeAlert((
|
self.theParent.makeAlert((
|
||||||
"Cannot backup project because the backup path does not exist. "
|
"Cannot backup project because the backup path does not exist. "
|
||||||
"Please set a valid backup location in Tools > Preferences."
|
"Please set a valid backup location in Tools > Preferences."
|
||||||
), nwAlert.WARN)
|
), nwAlert.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
cleanName = self.getFileSafeProjectName()
|
cleanName = self.getFileSafeProjectName()
|
||||||
baseDir = path.join(self.mainConf.backupPath, cleanName)
|
baseDir = path.abspath(path.join(self.mainConf.backupPath, cleanName))
|
||||||
if not path.isdir(baseDir):
|
if not path.isdir(baseDir):
|
||||||
try:
|
try:
|
||||||
mkdir(baseDir)
|
mkdir(baseDir)
|
||||||
@@ -556,6 +556,14 @@ class NWProject():
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if path.commonpath([self.projPath, baseDir]) == self.projPath:
|
||||||
|
self.theParent.makeAlert((
|
||||||
|
"Cannot backup project because the backup path is within the "
|
||||||
|
"project folder to be backed up. Please choose a different "
|
||||||
|
"backup path in Tools > Preferences."
|
||||||
|
), nwAlert.ERROR)
|
||||||
|
return False
|
||||||
|
|
||||||
archName = "Backup from %s" % formatTimeStamp(time(), fileSafe=True)
|
archName = "Backup from %s" % formatTimeStamp(time(), fileSafe=True)
|
||||||
baseName = path.join(baseDir, archName)
|
baseName = path.join(baseDir, archName)
|
||||||
|
|
||||||
@@ -565,7 +573,7 @@ class NWProject():
|
|||||||
self._writeLockFile()
|
self._writeLockFile()
|
||||||
if doNotify:
|
if doNotify:
|
||||||
self.theParent.makeAlert(
|
self.theParent.makeAlert(
|
||||||
"Backup archive file written to: '%s.zip'" % path.join(cleanName, archName),
|
"Backup archive file written to: %s.zip" % path.join(cleanName, archName),
|
||||||
nwAlert.INFO
|
nwAlert.INFO
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -594,7 +602,7 @@ class NWProject():
|
|||||||
else:
|
else:
|
||||||
if projPath.startswith("~"):
|
if projPath.startswith("~"):
|
||||||
projPath = path.expanduser(projPath)
|
projPath = path.expanduser(projPath)
|
||||||
self.projPath = projPath
|
self.projPath = path.abspath(projPath)
|
||||||
self.setProjectChanged(True)
|
self.setProjectChanged(True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user