diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-05-02 10:12:53 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-05-02 10:12:53 (GMT) |
commit | 2d488a40520e64708b34f5e28102f606d9bcb38e (patch) | |
tree | b242fdc40c2f7946f21b85a96929d7ab16f3685a /src/analysis/db | |
parent | d419908c21172b72e7782f460f385b33ad85f929 (diff) |
Moved archive temporary files.
Diffstat (limited to 'src/analysis/db')
-rw-r--r-- | src/analysis/db/cdb.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/analysis/db/cdb.c b/src/analysis/db/cdb.c index e909210..170bdfa 100644 --- a/src/analysis/db/cdb.c +++ b/src/analysis/db/cdb.c @@ -52,6 +52,7 @@ #include "../../common/pathname.h" #include "../../common/xml.h" #include "../../core/collections.h" +#include "../../core/params.h" @@ -60,8 +61,6 @@ - - /* Informations relatives à un client */ typedef struct _cdb_client { @@ -311,8 +310,10 @@ static void g_cdb_archive_finalize(GCdbArchive *archive) GCdbArchive *g_cdb_archive_new(const char *basedir, const rle_string *hash, const rle_string *user, DBError *error) { GCdbArchive *result; /* Adresse à retourner */ - struct stat finfo; /* Information sur l'archive */ + const char *tmpdir; /* Répertoire d'accueil */ + bool status; /* Bilan d'un consultation */ int ret; /* Retour d'un appel */ + struct stat finfo; /* Information sur l'archive */ result = g_object_new(G_TYPE_CDB_ARCHIVE, NULL); @@ -330,21 +331,17 @@ GCdbArchive *g_cdb_archive_new(const char *basedir, const rle_string *hash, cons /* Chemin des enregistrements temporaires */ - result->xml_desc = strdup(g_get_tmp_dir()); + status = g_generic_config_get_value(get_main_configuration(), MPK_TMPDIR, &tmpdir); + if (!status) goto gcan_no_tmp; - if (result->xml_desc[strlen(result->xml_desc) - 1] != G_DIR_SEPARATOR) - result->xml_desc = stradd(result->xml_desc, G_DIR_SEPARATOR_S); + ret = asprintf(&result->xml_desc, "%s" G_DIR_SEPARATOR_S "%s_desc.xml", tmpdir, result->hash.data); + if (ret == -1) goto gcan_no_tmp; - result->xml_desc = stradd(result->xml_desc, result->hash.data); - result->xml_desc = stradd(result->xml_desc, "_desc.xml"); + ret = ensure_path_exists(result->xml_desc); + if (ret == -1) goto gcan_no_tmp; - result->sql_db = strdup(g_get_tmp_dir()); - - if (result->sql_db[strlen(result->sql_db) - 1] != G_DIR_SEPARATOR) - result->sql_db = stradd(result->sql_db, G_DIR_SEPARATOR_S); - - result->sql_db = stradd(result->sql_db, result->hash.data); - result->sql_db = stradd(result->sql_db, "_db.sql"); + ret = asprintf(&result->sql_db, "%s" G_DIR_SEPARATOR_S "%s_db.sql", tmpdir, result->hash.data); + if (ret == -1) goto gcan_no_tmp; /* Création de l'archive si elle n'existe pas */ @@ -388,6 +385,8 @@ GCdbArchive *g_cdb_archive_new(const char *basedir, const rle_string *hash, cons return result; + gcan_no_tmp: + gcan_error: g_object_unref(G_OBJECT(result)); |