[calls] sip: provider: Skip creating credential directory on test



commit 876375a39bef8b81739b3481e7a6af64991e4dd4
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Fri Sep 3 00:08:05 2021 +0200

    sip: provider: Skip creating credential directory on test
    
    As it's not guaranteed that the home directory is always writable
    during the build. Debspawn for example does not allow this
    and we might get such a warning:
    
    `CallsSipProvider-WARNING **: 21:58:14.839: Failed to create directory '/home/salsaci/.config/calls': 13`

 plugins/sip/calls-sip-provider.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/plugins/sip/calls-sip-provider.c b/plugins/sip/calls-sip-provider.c
index 82075416..faedf3e0 100644
--- a/plugins/sip/calls-sip-provider.c
+++ b/plugins/sip/calls-sip-provider.c
@@ -581,6 +581,7 @@ calls_sip_provider_init (CallsSipProvider *self)
 {
   g_autofree char *directory = NULL;
   const char *filename_env = g_getenv ("CALLS_SIP_ACCOUNT_FILE");
+  const char *sip_test_env = g_getenv ("CALLS_SIP_TEST");
 
   self->origins = g_list_store_new (CALLS_TYPE_ORIGIN);
 
@@ -592,12 +593,14 @@ calls_sip_provider_init (CallsSipProvider *self)
                                        SIP_ACCOUNT_FILE,
                                        NULL);
 
-  directory = g_path_get_dirname (self->filename);
-  if (g_mkdir_with_parents (directory, 0750) == -1) {
-    int err_save = errno;
-    g_warning ("Failed to create directory '%s': %d\n"
-               "Can not store credentials persistently!",
-               directory, err_save);
+  if (!sip_test_env || sip_test_env[0] == '\0') {
+    directory = g_path_get_dirname (self->filename);
+    if (g_mkdir_with_parents (directory, 0750) == -1) {
+      int err_save = errno;
+      g_warning ("Failed to create directory '%s': %d\n"
+                 "Can not store credentials persistently!",
+                 directory, err_save);
+    }
   }
 
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]