diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-06-13 15:02:43 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-06-13 15:02:43 +0200 |
commit | 914c6752dd4ac3421311817d585cd687cec693e4 (patch) | |
tree | 95c569c99b738fd4e81bd43ef489d4ea81f2bfbd | |
parent | 74e061165a808883c5b17ff356bde60fa335cbda (diff) | |
download | profani-tty-914c6752dd4ac3421311817d585cd687cec693e4.tar.gz |
Fix reading/writing linked files
"base" was not really base but the filename :-) Fix https://github.com/profanity-im/profanity/issues/1362
-rw-r--r-- | src/common.c | 1 | ||||
-rw-r--r-- | src/config/accounts.c | 2 | ||||
-rw-r--r-- | src/config/preferences.c | 2 | ||||
-rw-r--r-- | src/plugins/settings.c | 2 | ||||
-rw-r--r-- | src/xmpp/connection.c | 2 |
5 files changed, 5 insertions, 4 deletions
diff --git a/src/common.c b/src/common.c index 1de5f4ba..cf072026 100644 --- a/src/common.c +++ b/src/common.c @@ -307,6 +307,7 @@ get_file_or_linked(char *loc, char *basedir) // if relative, add basedir if (!g_str_has_prefix(true_loc, "/") && !g_str_has_prefix(true_loc, "~")) { GString *base_str = g_string_new(basedir); + g_string_append(base_str, "/"); g_string_append(base_str, true_loc); free(true_loc); true_loc = base_str->str; diff --git a/src/config/accounts.c b/src/config/accounts.c index 1c194a9a..92bf19d0 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -969,7 +969,7 @@ _save_accounts(void) gsize g_data_size; 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); g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL); g_chmod(accounts_loc, S_IRUSR | S_IWUSR); diff --git a/src/config/preferences.c b/src/config/preferences.c index d1c1d900..093d7679 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1665,7 +1665,7 @@ _save_prefs(void) { gsize g_data_size; 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); g_file_set_contents(true_loc, g_prefs_data, g_data_size, NULL); diff --git a/src/plugins/settings.c b/src/plugins/settings.c index 5ed32426..386c80a0 100644 --- a/src/plugins/settings.c +++ b/src/plugins/settings.c @@ -176,7 +176,7 @@ _save_settings(void) gchar *g_data = g_key_file_to_data(settings, &g_data_size, NULL); 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); g_free(base); g_file_set_contents(true_loc, g_data, g_data_size, NULL); diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index e6d72d84..8c875e63 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -698,7 +698,7 @@ static void _random_bytes_init(void) gsize g_data_size; 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); g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL); |