diff options
-rw-r--r-- | src/analysis/db/cdb.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/analysis/db/cdb.c b/src/analysis/db/cdb.c index bcd3ed3..7044853 100644 --- a/src/analysis/db/cdb.c +++ b/src/analysis/db/cdb.c @@ -316,7 +316,7 @@ GCdbArchive *g_cdb_archive_new(const char *basedir, const rle_string *hash, cons result->filename = strdup(basedir); result->filename = stradd(result->filename, G_DIR_SEPARATOR_S); result->filename = stradd(result->filename, hash->data); - result->filename = stradd(result->filename, ".tar.xz"); + result->filename = stradd(result->filename, ".cdb.tar.xz"); if (!mkpath(result->filename)) goto gcan_error; @@ -415,7 +415,7 @@ static bool g_cdb_archive_read(GCdbArchive *archive) archive_read_support_format_all(in); ret = archive_read_open_filename(in, archive->filename, 10240 /* ?! */); - if (ret != ARCHIVE_OK) goto gcar_exit; + if (ret != ARCHIVE_OK) goto gcar_bad_archive; for (ret = archive_read_next_header(in, &entry); ret == ARCHIVE_OK; @@ -445,13 +445,18 @@ static bool g_cdb_archive_read(GCdbArchive *archive) } - archive_read_close(in); - archive_read_free(in); + if (ret != ARCHIVE_EOF) + goto gcar_exit; result = true; gcar_exit: + gcar_bad_archive: + + archive_read_close(in); + archive_read_free(in); + return result; } @@ -483,7 +488,7 @@ DBError g_cdb_archive_write(const GCdbArchive *archive) archive_write_set_format_gnutar(out); ret = archive_write_open_filename(out, archive->filename); - if (ret != ARCHIVE_OK) goto gcaw_exit; + if (ret != ARCHIVE_OK) goto gcaw_bad_archive; status = add_file_into_archive(out, archive->xml_desc, "desc.xml"); @@ -525,8 +530,9 @@ DBError g_cdb_archive_write(const GCdbArchive *archive) } - gcaw_exit: + gcaw_bad_archive: + archive_write_close(out); archive_write_free(out); return result; |