From 348e62cd3e94c75aa65e867197655cb1bb63096e Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Tue, 8 Aug 2023 19:59:57 +0200 Subject: [PATCH] Change default backup folder to HOME/Backups Signed-off-by: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> --- novelwriter/config.py | 7 ++++--- novelwriter/core/project.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/novelwriter/config.py b/novelwriter/config.py index 1edffa10..c60efee1 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -68,6 +68,7 @@ class Config: self._confPath = confRoot.absolute() / self.appHandle # The user config location self._dataPath = dataRoot.absolute() / self.appHandle # The user data location self._homePath = Path.home().absolute() # The user's home directory + self._backPath = self._homePath / "Backups" self._appPath = Path(__file__).parent.absolute() self._appRoot = self._appPath.parent @@ -174,7 +175,7 @@ class Config: # User Paths self._lastPath = self._homePath # The user's last used path - self._backupPath = self._homePath # Backup path to use, can be none + self._backupPath = self._backPath # Backup path to use, can be none # Spell Checking Settings self.spellLanguage = "en" @@ -355,7 +356,7 @@ class Config: def setBackupPath(self, backupPath: Path | str): """Set the current backup path.""" - self._backupPath = checkPath(backupPath, self._homePath) + self._backupPath = checkPath(backupPath, self._backPath) return def setTextFont(self, family: str | None, pointSize: int = 12): @@ -418,7 +419,7 @@ class Config: if isinstance(self._backupPath, Path): if self._backupPath.is_dir(): return self._backupPath - return self._homePath + return self._backPath def errorText(self) -> str: """Compile and return error messages from the initialisation of diff --git a/novelwriter/core/project.py b/novelwriter/core/project.py index dfe7a737..839ab335 100644 --- a/novelwriter/core/project.py +++ b/novelwriter/core/project.py @@ -427,7 +427,7 @@ class NWProject(QObject): backupPath = CONFIG.backupPath() baseDir = backupPath / cleanName try: - baseDir.mkdir(exist_ok=True) + baseDir.mkdir(exist_ok=True, parents=True) except Exception as exc: self.mainGui.makeAlert(self.tr( "Could not create backup folder."