From 96ed84b28da95c2f3ab011f17a77f1e413a69e46 Mon Sep 17 00:00:00 2001 From: Manu <3916435+m3nu@users.noreply.github.com> Date: Sun, 18 Apr 2021 21:24:49 +0800 Subject: [PATCH] Check for full disk access on macOS (#952) --- src/vorta/application.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/vorta/application.py b/src/vorta/application.py index 50ee40ef..da5b1066 100644 --- a/src/vorta/application.py +++ b/src/vorta/application.py @@ -77,6 +77,9 @@ class VortaApp(QtSingleApplication): self.backup_log_event.connect(self.react_to_log) self.aboutToQuit.connect(self.quit_app_action) self.set_borg_details_action() + if sys.platform == 'darwin': + self.check_darwin_permissions() + self.installEventFilter(self) def create_backups_cmdline(self, profile_name): @@ -182,6 +185,30 @@ class VortaApp(QtSingleApplication): msg.setStandardButtons(QMessageBox.Ok) msg.exec() + def check_darwin_permissions(self): + """ + macOS restricts access to certain folders by default. For some folders, the user + will get a prompt (e.g. Documents, Downloads), while others will cause file access + errors. + + This function tries reading a file that is known to be restricted and warn the user about + incomplete backups. + """ + test_path = os.path.expanduser('~/Library/Cookies') + if os.path.exists(test_path) and not os.access(test_path, os.R_OK): + msg = QMessageBox() + msg.setIcon(QMessageBox.Warning) + msg.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse) + msg.setText(self.tr("Vorta needs Full Disk Access for complete Backups")) + msg.setInformativeText(self.tr( + "Without this, some files won't be accessible and you may end up with an incomplete " + "backup. Please set Full Disk Access permission for Vorta in " + "" + "System Preferences > Security & Privacy." + )) + msg.setStandardButtons(QMessageBox.Ok) + msg.exec() + def react_to_log(self, mgs, context): """ Trigger Vorta actions based on Borg logs. E.g. repo lock.