diff options
author | ShadowNinja <shadowninja@minetest.net> | 2015-12-18 15:42:12 -0500 |
---|---|---|
committer | sapier <sapier AT gmx dot net> | 2015-12-30 00:14:30 +0100 |
commit | 9719aded5430dd57591310c9cae06944dc345d42 (patch) | |
tree | 74f068bb030fcd8f7807cf336a9cdf28318d5c80 /src | |
parent | cb30facda0351a148005bfe33377c2ecc8f97af8 (diff) | |
download | minetest-9719aded5430dd57591310c9cae06944dc345d42.tar.gz minetest-9719aded5430dd57591310c9cae06944dc345d42.tar.bz2 minetest-9719aded5430dd57591310c9cae06944dc345d42.zip |
Fix cache path with RUN_IN_PLACE
If an `XDG_CACHE_HOME` can't be found or `RUN_IN_PLACE` is enabled,
`path_cache` is left at its default of `$PATH_USER/cache`
(at a time when `PATH_USER` is `..`), rather than being reset to
`$PATH_USER/cache` after `PATH_USER` has been properly set.
Diffstat (limited to 'src')
-rw-r--r-- | src/porting.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/porting.cpp b/src/porting.cpp index 4a72e90fd..223299892 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -527,6 +527,7 @@ void initializePaths() path_share = execpath; path_user = execpath; } + path_cache = path_user + DIR_DELIM + "cache"; #else infostream << "Using system-wide paths (NOT RUN_IN_PLACE)" << std::endl; @@ -536,16 +537,16 @@ void initializePaths() // Initialize path_cache // First try $XDG_CACHE_HOME/PROJECT_NAME const char *cache_dir = getenv("XDG_CACHE_HOME"); + const char *home_dir = getenv("HOME"); if (cache_dir) { path_cache = std::string(cache_dir) + DIR_DELIM + PROJECT_NAME; - } else { + } else if (home_dir) { // Then try $HOME/.cache/PROJECT_NAME - const char *home_dir = getenv("HOME"); - if (home_dir) { - path_cache = std::string(home_dir) + DIR_DELIM + ".cache" - + DIR_DELIM + PROJECT_NAME; - } - // If neither works, leave it at $PATH_USER/cache + path_cache = std::string(home_dir) + DIR_DELIM + ".cache" + + DIR_DELIM + PROJECT_NAME; + } else { + // If neither works, use $PATH_USER/cache + path_cache = path_user + DIR_DELIM + "cache"; } // Migrate cache folder to new location if possible migrateCachePath(); |