e config - fix config fallback handling - it was broken

loaded the wrong filename pattern due to a change i made ages to it
from file.N.cfg to file.cfg.N.

@fix
pull/7/head
Carsten Haitzler 5 months ago
parent a1600a137f
commit 027a810e84
  1. 37
      src/bin/e_config.c

@ -122,6 +122,24 @@ _e_config_profile_name_get(Eet_File *ef)
s = eina_stringshare_add_length(data, data_len);
free(data);
}
if (s)
{
char buf[PATH_MAX];
char buf2[PATH_MAX];
e_user_dir_snprintf(buf, sizeof(buf), "config/%s", s);
if (!ecore_file_is_dir(buf))
{
snprintf(buf2, sizeof(buf2), "config/%s", s);
e_prefix_data_concat_static(buf, buf2);
if (!ecore_file_is_dir(buf))
{
printf("CF: warning - profile [%s] dir does not exist in user or system dirs\n", s);
eina_stringshare_del(s);
s = NULL;
}
}
}
return s;
}
@ -172,7 +190,7 @@ _e_config_pending_file_del(const char *path)
eina_hash_del(_e_config_pending_files, path, ef);
eina_lock_release(&_e_config_pending_files_lock);
err = eet_close(ef);
eet_close(ef);
switch (err)
{
case EET_ERROR_NONE:
@ -1045,19 +1063,24 @@ e_config_init(void)
for (i = 1; i <= _e_config_revisions; i++)
{
e_user_dir_snprintf(buf, sizeof(buf), "config/profile.%i.cfg", i);
e_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg.%i", i);
ef = eet_open(buf, EET_FILE_MODE_READ);
if (ef)
{
printf("CF: warning - falling back to %s\n", buf);
_e_config_profile = _e_config_profile_name_get(ef);
eet_close(ef);
ef = NULL;
if (_e_config_profile) break;
printf("CF: warning - fallback to %s can't read profile\n", buf);
}
else if (ecore_file_exists(buf))
printf("CF: warning - fallback to %s failing to open\n", buf);
}
if (!_e_config_profile)
{
/* use system if no user profile config */
printf("CF: fallback to system profile config file\n");
e_prefix_data_concat_static(buf, "data/config/profile.cfg");
ef = eet_open(buf, EET_FILE_MODE_READ);
}
@ -1067,6 +1090,8 @@ e_config_init(void)
_e_config_profile = _e_config_profile_name_get(ef);
eet_close(ef);
ef = NULL;
if (!_e_config_profile)
printf("CF: warning - can't read profile\n");
}
if (!_e_config_profile)
{
@ -2175,16 +2200,21 @@ e_config_domain_load(const char *domain, E_Config_DD *edd)
for (i = 1; i <= _e_config_revisions; i++)
{
e_user_dir_snprintf(buf, sizeof(buf), "config/%s/%s.%i.cfg",
e_user_dir_snprintf(buf, sizeof(buf), "config/%s/%s.cfg.%i",
_e_config_profile, domain, i);
ef = eet_open(buf, EET_FILE_MODE_READ);
if (ef)
{
printf("CF: warning - falling back to %s\n", buf);
data = eet_data_read(ef, edd, "config");
eet_close(ef);
if (data) return data;
printf("CF: warning - fallback to %s can't read config\n", buf);
}
else if (ecore_file_exists(buf))
printf("CF: warning - fallback to %s failing to open\n", buf);
}
printf("CF: fallback to system config config file for [%s]\n", domain);
return e_config_domain_system_load(domain, edd);
}
@ -2204,6 +2234,7 @@ e_config_domain_system_load(const char *domain, E_Config_DD *edd)
eet_close(ef);
return data;
}
printf("CF: system config load for %s failed\n", buf);
return data;
}

Loading…
Cancel
Save