From 48e5f28cf313789cf1928e424135c2a24cba028f Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sat, 9 Feb 2019 14:09:32 +0100 Subject: [PATCH] add a path is writeable check to the restore function --- borg_qt/helper.py | 7 +++++++ borg_qt/main_window.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/borg_qt/helper.py b/borg_qt/helper.py index 2b46078..0cb93a0 100644 --- a/borg_qt/helper.py +++ b/borg_qt/helper.py @@ -47,3 +47,10 @@ def create_path(path): def remove_path(path): if os.path.exists(path): shutil.rmtree(path) + + +def check_path(path): + if os.access(path, os.W_OK): + return True + exception = Exception("The selected path isn't writeable!") + show_error(exception) diff --git a/borg_qt/main_window.py b/borg_qt/main_window.py index ebcdabd..54f4861 100644 --- a/borg_qt/main_window.py +++ b/borg_qt/main_window.py @@ -8,7 +8,7 @@ from PyQt5.QtWidgets import (QMainWindow, QFileSystemModel, QFileDialog, from config import Config from helper import (BorgException, show_error, convert_size, open_path, - create_path, remove_path) + create_path, remove_path, check_path) import borg_interface as borg from progress import ProgressDialog @@ -130,7 +130,7 @@ class MainWindow(QMainWindow): target_path = None show_error(error) - if target_path and archive_name: + if check_path(target_path) and archive_name: try: restore_path = os.path.join(target_path, archive_name) create_path(restore_path)