diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-10-20 13:01:24 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-10-20 13:01:24 (GMT) |
commit | b1c08dd388a86d9a9d7c379ca143ae85310c3c68 (patch) | |
tree | a1a078e09ce4d8bd0db24c9139d5fad640353d79 /src/analysis/db/snapshot.c | |
parent | f2c79b92f09fa796afe66d5886e678e9a7275ac1 (diff) |
Provided a way to update snapshots name and description.
Diffstat (limited to 'src/analysis/db/snapshot.c')
-rw-r--r-- | src/analysis/db/snapshot.c | 135 |
1 files changed, 134 insertions, 1 deletions
diff --git a/src/analysis/db/snapshot.c b/src/analysis/db/snapshot.c index 79128ef..2cd50f6 100644 --- a/src/analysis/db/snapshot.c +++ b/src/analysis/db/snapshot.c @@ -942,6 +942,9 @@ bool g_db_snapshot_fill(GDbSnapshot *snap, struct archive *archive) node = find_snapshot_node(snap->nodes, &node_id); + if (node == NULL) + break; + if (!setup_snapshot_node_db_path(node, snap->tmpdir, snap->hash)) break; @@ -1059,7 +1062,7 @@ sqlite3 *g_db_snapshot_get_database(const GDbSnapshot *snap, const snapshot_id_t if (node == NULL) { - log_variadic_message(LMT_ERROR, _("Snapshot not found for id '%s'"), *id); + log_variadic_message(LMT_ERROR, _("Snapshot not found for id '%s'"), snapshot_id_as_string(id)); result = NULL; } @@ -1105,3 +1108,133 @@ bool g_db_snapshot_pack_all(const GDbSnapshot *snap, packed_buffer *pbuf) return result; } + + +/****************************************************************************** +* * +* Paramètres : snap = gestionnaire d'instantanés à consulter. * +* pbuf = paquet de données où venir puiser les infos. * +* * +* Description : Actualise la désignation d'un instantané donné. * +* * +* Retour : Bilan de l'opération sous forme de code d'erreur. * +* * +* Remarques : - * +* * +******************************************************************************/ + +DBError g_db_snapshot_set_name(const GDbSnapshot *snap, packed_buffer *pbuf) +{ + DBError result; /* Conclusion à retourner */ + snapshot_id_t id; /* Identifiant d'instantané */ + bool status; /* Bilan d'une récupération */ + rle_string string; /* Chaîne à transmettre */ + snapshot_node_t *node; /* Instantané trouvé */ + + result = DBE_NONE; + + /* Lecture des arguments */ + + setup_empty_snapshot_id(&id); + + status = unpack_snapshot_id(&id, pbuf); + if (!status) + { + result = DBE_BAD_EXCHANGE; + goto bad_exchange; + } + + setup_empty_rle_string(&string); + + status = unpack_rle_string(&string, pbuf); + if (!status) + { + result = DBE_BAD_EXCHANGE; + goto bad_exchange; + } + + /* Traitement */ + + node = find_snapshot_node(snap->nodes, &id); + + if (node == NULL) + { + log_variadic_message(LMT_ERROR, _("Snapshot not found for id '%s'"), snapshot_id_as_string(&id)); + result = DBE_SNAPSHOT_NOT_FOUND; + } + + else + set_snapshot_info_name(&node->info, get_rle_string(&string)); + + exit_rle_string(&string); + + bad_exchange: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : snap = gestionnaire d'instantanés à consulter. * +* pbuf = paquet de données où venir puiser les infos. * +* * +* Description : Actualise la description d'un instantané donné. * +* * +* Retour : Bilan de l'opération sous forme de code d'erreur. * +* * +* Remarques : - * +* * +******************************************************************************/ + +DBError g_db_snapshot_set_desc(const GDbSnapshot *snap, packed_buffer *pbuf) +{ + DBError result; /* Conclusion à retourner */ + snapshot_id_t id; /* Identifiant d'instantané */ + bool status; /* Bilan d'une récupération */ + rle_string string; /* Chaîne à transmettre */ + snapshot_node_t *node; /* Instantané trouvé */ + + result = DBE_NONE; + + /* Lecture des arguments */ + + setup_empty_snapshot_id(&id); + + status = unpack_snapshot_id(&id, pbuf); + if (!status) + { + result = DBE_BAD_EXCHANGE; + goto bad_exchange; + } + + setup_empty_rle_string(&string); + + status = unpack_rle_string(&string, pbuf); + if (!status) + { + result = DBE_BAD_EXCHANGE; + goto bad_exchange; + } + + /* Traitement */ + + node = find_snapshot_node(snap->nodes, &id); + + if (node == NULL) + { + log_variadic_message(LMT_ERROR, _("Snapshot not found for id '%s'"), snapshot_id_as_string(&id)); + result = DBE_SNAPSHOT_NOT_FOUND; + } + + else + set_snapshot_info_desc(&node->info, get_rle_string(&string)); + + exit_rle_string(&string); + + bad_exchange: + + return result; + +} |