Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unable for initialization by JDIM_CACHE on compat mode #147

Merged
merged 1 commit into from
Nov 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,26 @@ std::string CACHE::path_root()
{
if( root_path.empty() ){

root_path = MISC::getenv_limited( "JDIM_CACHE", MAX_SAFE_PATH );
if( root_path.empty() ) {
std::string jdim_cache = MISC::getenv_limited( "JDIM_CACHE", MAX_SAFE_PATH );
if( jdim_cache.empty() ) {
#ifdef ENABLE_COMPAT_CACHE_DIR
root_path = MISC::getenv_limited( ENV_HOME, MAX_SAFE_PATH ) + "/.jd/";
#else
root_path = Glib::get_user_cache_dir() + "/jdim/";
if( CACHE::file_exists( root_path ) != CACHE::EXIST_DIR )
#endif
{
root_path = Glib::get_user_cache_dir() + "/jdim/";
}
}
else {
root_path = std::move( jdim_cache );
}
else if( root_path[ 0 ] == '~' ){

if( root_path.front() == '~' ) {
std::string home = MISC::getenv_limited( ENV_HOME , MAX_SAFE_PATH );
root_path.replace( 0, 1, home );
}

if( root_path.back() != '/' ) root_path.push_back( '/' );

#ifdef ENABLE_COMPAT_CACHE_DIR
if( CACHE::file_exists( root_path ) != CACHE::EXIST_DIR ) {
root_path = Glib::get_user_cache_dir() + "/jdim/";
}
#endif
}

return root_path;
Expand Down