1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Fix reading/writing linked files

"base" was not really base but the filename :-)

Fix https://github.com/profanity-im/profanity/issues/1362
This commit is contained in:
Michael Vetter 2020-06-13 15:02:43 +02:00
parent 74e061165a
commit 914c6752dd
5 changed files with 5 additions and 4 deletions

View File

@ -307,6 +307,7 @@ get_file_or_linked(char *loc, char *basedir)
// if relative, add basedir // if relative, add basedir
if (!g_str_has_prefix(true_loc, "/") && !g_str_has_prefix(true_loc, "~")) { if (!g_str_has_prefix(true_loc, "/") && !g_str_has_prefix(true_loc, "~")) {
GString *base_str = g_string_new(basedir); GString *base_str = g_string_new(basedir);
g_string_append(base_str, "/");
g_string_append(base_str, true_loc); g_string_append(base_str, true_loc);
free(true_loc); free(true_loc);
true_loc = base_str->str; true_loc = base_str->str;

View File

@ -969,7 +969,7 @@ _save_accounts(void)
gsize g_data_size; gsize g_data_size;
gchar *g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL); gchar *g_accounts_data = g_key_file_to_data(accounts, &g_data_size, NULL);
gchar *base = g_path_get_basename(accounts_loc); gchar *base = g_path_get_dirname(accounts_loc);
gchar *true_loc = get_file_or_linked(accounts_loc, base); gchar *true_loc = get_file_or_linked(accounts_loc, base);
g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL); g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL);
g_chmod(accounts_loc, S_IRUSR | S_IWUSR); g_chmod(accounts_loc, S_IRUSR | S_IWUSR);

View File

@ -1665,7 +1665,7 @@ _save_prefs(void)
{ {
gsize g_data_size; gsize g_data_size;
gchar *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL); gchar *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
gchar *base = g_path_get_basename(prefs_loc); gchar *base = g_path_get_dirname(prefs_loc);
gchar *true_loc = get_file_or_linked(prefs_loc, base); gchar *true_loc = get_file_or_linked(prefs_loc, base);
g_file_set_contents(true_loc, g_prefs_data, g_data_size, NULL); g_file_set_contents(true_loc, g_prefs_data, g_data_size, NULL);

View File

@ -176,7 +176,7 @@ _save_settings(void)
gchar *g_data = g_key_file_to_data(settings, &g_data_size, NULL); gchar *g_data = g_key_file_to_data(settings, &g_data_size, NULL);
char *fileloc = files_get_data_path(FILE_PLUGIN_SETTINGS); char *fileloc = files_get_data_path(FILE_PLUGIN_SETTINGS);
gchar *base = g_path_get_basename(fileloc); gchar *base = g_path_get_dirname(fileloc);
gchar *true_loc = get_file_or_linked(fileloc, base); gchar *true_loc = get_file_or_linked(fileloc, base);
g_free(base); g_free(base);
g_file_set_contents(true_loc, g_data, g_data_size, NULL); g_file_set_contents(true_loc, g_data, g_data_size, NULL);

View File

@ -698,7 +698,7 @@ static void _random_bytes_init(void)
gsize g_data_size; gsize g_data_size;
gchar *g_accounts_data = g_key_file_to_data(rndbytes, &g_data_size, NULL); gchar *g_accounts_data = g_key_file_to_data(rndbytes, &g_data_size, NULL);
gchar *base = g_path_get_basename(rndbytes_loc); gchar *base = g_path_get_dirname(rndbytes_loc);
gchar *true_loc = get_file_or_linked(rndbytes_loc, base); gchar *true_loc = get_file_or_linked(rndbytes_loc, base);
g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL); g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL);