From efe1d71d35ebfdd210521a3c2a67acc464ddcf61 Mon Sep 17 00:00:00 2001 From: Kenneth Chew <79120643+kthchew@users.noreply.github.com> Date: Sun, 15 Dec 2024 01:02:50 -0500 Subject: [PATCH] Generate security-scoped bookmarks on startup Signed-off-by: Kenneth Chew <79120643+kthchew@users.noreply.github.com> --- launcher/Application.cpp | 15 +++++++++++++++ launcher/CMakeLists.txt | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index a532db2cf..90f5a45cb 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -969,6 +969,21 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) // Themes m_themeManager = std::make_unique(); +#ifdef Q_OS_MACOS + // for macOS: getting directory settings will generate URL security-scoped bookmarks if needed and not present + // this facilitates a smooth transition from a non-sandboxed version of the launcher, that likely can access the directory, + // and a sandboxed version that can't access the directory without a bookmark + // this section can likely be removed once the sandboxed version has been released for a while and migrations aren't done anymore + { + m_settings->get("InstanceDir"); + m_settings->get("CentralModsDir"); + m_settings->get("IconsDir"); + m_settings->get("DownloadsDir"); + m_settings->get("SkinsDir"); + m_settings->get("JavaDir"); + } +#endif + // initialize and load all instances { auto InstDirSetting = m_settings->getSetting("InstanceDir"); diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index ecdab490e..b5ba3fe55 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1177,8 +1177,8 @@ if (APPLE) set(LAUNCHER_SOURCES ${LAUNCHER_SOURCES} - macsandbox/SecurityBookmarkFileAccess.h - macsandbox/SecurityBookmarkFileAccess.mm + macsandbox/SecurityBookmarkFileAccess.h + macsandbox/SecurityBookmarkFileAccess.mm ) endif()