diff options
author | Steffen Jaeckel <jaeckel-floss@eyet-services.de> | 2022-03-13 11:58:56 +0100 |
---|---|---|
committer | Steffen Jaeckel <jaeckel-floss@eyet-services.de> | 2022-03-13 14:15:02 +0100 |
commit | b8e46552bffc559263e86b2dcc0331b3f47065b7 (patch) | |
tree | edd714bd6487ae39a3d6b7c77f799391b5071151 /src/pgp | |
parent | 764a7fb71b6cc401ed77233bbcd4d67201f9ca85 (diff) | |
download | profani-tty-b8e46552bffc559263e86b2dcc0331b3f47065b7.tar.gz |
add `files_file_in_account_data_path()`
As all parts of the code invoking the `files_get_account_data_path()` function did the same afterwards, a function has been added with the same behavior. 1. create path 2. `mkdir` of that path 3. return final path Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Diffstat (limited to 'src/pgp')
-rw-r--r-- | src/pgp/gpg.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/src/pgp/gpg.c b/src/pgp/gpg.c index 549f9d3b..a1300f80 100644 --- a/src/pgp/gpg.c +++ b/src/pgp/gpg.c @@ -161,27 +161,13 @@ p_gpg_close(void) void p_gpg_on_connect(const char* const barejid) { - gchar* pubsfile = files_get_account_data_path(DIR_PGP, barejid); - - // mkdir if doesn't exist for account - errno = 0; - int res = g_mkdir_with_parents(pubsfile, S_IRWXU); - if (res == -1) { - const char* errmsg = strerror(errno); - if (errmsg) { - log_error("Error creating directory: %s, %s", pubsfile, errmsg); - } else { - log_error("Error creating directory: %s", pubsfile); - } + pubsloc = files_file_in_account_data_path(DIR_PGP, barejid, "pubkeys"); + if (!pubsloc) { + log_error("Could not create directory for account %s.", barejid); + cons_show_error("Could not create directory for account %s.", barejid); + return; } - // create or read publickeys - GString* pubtmp = g_string_new(pubsfile); - g_string_append(pubtmp, "/pubkeys"); - pubsloc = pubtmp->str; - g_string_free(pubtmp, FALSE); - g_free(pubsfile); - if (g_file_test(pubsloc, G_FILE_TEST_EXISTS)) { g_chmod(pubsloc, S_IRUSR | S_IWUSR); } |