From 994d70b226d4881a69b8f60282536a48fbbf9b23 Mon Sep 17 00:00:00 2001 From: Vladislav Nepogodin Date: Thu, 23 Sep 2021 02:10:00 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hello.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/hello.cpp b/src/hello.cpp index 60bad2c..bf01b51 100644 --- a/src/hello.cpp +++ b/src/hello.cpp @@ -391,10 +391,15 @@ void Hello::set_locale(const std::string_view& use_locale) noexcept { } void Hello::set_autostart(const bool& autostart) noexcept { - if (autostart && !fs::is_regular_file(fix_path(m_preferences["autostart_path"]))) { - fs::create_symlink(m_preferences["desktop_path"], fix_path(m_preferences["autostart_path"])); - } else if (!autostart && fs::is_regular_file(fix_path(m_preferences["autostart_path"]))) { - fs::remove(fix_path(m_preferences["autostart_path"])); + fs::path autostart_path{fix_path(m_preferences["autostart_path"])}; + const auto& config_dir = autostart_path.parent_path(); + if (!fs::exists(config_dir)) { + fs::create_directories(config_dir); + } + if (autostart && !fs::is_regular_file(autostart_path)) { + fs::create_symlink(m_preferences["desktop_path"], autostart_path); + } else if (!autostart && fs::is_regular_file(autostart_path)) { + fs::remove(autostart_path); } m_autostart = autostart; }