Skip to content

Commit

Permalink
Merge pull request #777 from dl6tom/master
Browse files Browse the repository at this point in the history
ensure XDG_CACHE_HOME exists
  • Loading branch information
carrotIndustries authored Jun 9, 2024
2 parents d99bb88 + 9892670 commit 512bba8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/imp/imp_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int main(int argc, char *argv[])
auto pool_base_path = Glib::getenv("HORIZON_POOL");
horizon::setup_locale();

horizon::create_config_dir();
horizon::create_cache_and_config_dir();

std::unique_ptr<horizon::ImpBase> imp = nullptr;
if (mode_sch) {
Expand Down
2 changes: 1 addition & 1 deletion src/pool-prj-mgr/pool-prj-mgr-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main(int argc, char *argv[])
gtk_disable_setlocale();
auto application = horizon::PoolProjectManagerApplication::create();
horizon::setup_locale();
horizon::create_config_dir();
horizon::create_cache_and_config_dir();
horizon::PoolManager::init();
horizon::AutomaticPreferences::get();
horizon::StockInfoProvider::init_db();
Expand Down
2 changes: 1 addition & 1 deletion src/pr-review/pr-review.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ int main(int c_argc, char *c_argv[])
Gio::init();
PoolManager::init();
git_libgit2_init();
create_config_dir();
create_cache_and_config_dir();

Reviewer rev;
return rev.main(c_argc, c_argv);
Expand Down
2 changes: 1 addition & 1 deletion src/python_module/horizonmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PyMODINIT_FUNC PyInit_horizon(void)
Gio::init();
horizon::PoolManager::init();
horizon::setup_locale();
horizon::create_config_dir();
horizon::create_cache_and_config_dir();

if (PyType_Ready(&ProjectType) < 0)
return NULL;
Expand Down
9 changes: 6 additions & 3 deletions src/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include <fstream>
#include <giomm.h>
#include <glibmm/miscutils.h>
#include <glib/gfileutils.h>
#include <glib/gstdio.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef G_OS_WIN32
#include <windows.h>
Expand Down Expand Up @@ -215,11 +217,12 @@ std::string get_config_dir()
return Glib::build_filename(Glib::get_user_config_dir(), "horizon");
}

void create_config_dir()
void create_cache_and_config_dir()
{
auto cache_dir = Glib::get_user_cache_dir();
g_mkdir_with_parents(cache_dir.c_str(), S_IRWXU);
auto config_dir = get_config_dir();
if (!Glib::file_test(config_dir, Glib::FILE_TEST_EXISTS))
Gio::File::create_for_path(config_dir)->make_directory_with_parents();
g_mkdir_with_parents(config_dir.c_str(), S_IRWXU);
}

void replace_backslash(std::string &path)
Expand Down
2 changes: 1 addition & 1 deletion src/util/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool endswith(const std::string &haystack, const std::string &needle);

int strcmp_natural(const std::string &a, const std::string &b);
int strcmp_natural(const char *a, const char *b);
void create_config_dir();
void create_cache_and_config_dir();
std::string get_config_dir();

void replace_backslash(std::string &path);
Expand Down

0 comments on commit 512bba8

Please sign in to comment.