]> git.seodisparate.com - SimpleArchiver/commitdiff
Fix edge case where only empty files are archived
authorStephen Seo <seo.disparate@gmail.com>
Thu, 19 Dec 2024 04:41:58 +0000 (13:41 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Fri, 20 Dec 2024 02:12:53 +0000 (11:12 +0900)
src/archiver.c

index 858a77dcce9c05682e879f7457b3cc1a11121bfe..4b947f0834e8dfdbd4a9927f505fa2291ddd1085 100644 (file)
@@ -2503,7 +2503,7 @@ int simple_archiver_write_v1(FILE *out_f, SDArchiverState *state,
       return SDAS_INTERNAL_ERROR;
     }
     free(ptrs);
-    if (current_size > 0 && current_count > 0) {
+    if ((chunk_counts->count == 0 || current_size > 0) && current_count > 0) {
       uint64_t *count = malloc(sizeof(uint64_t));
       *count = current_count;
       simple_archiver_list_add(chunk_counts, count, NULL);
@@ -3371,7 +3371,7 @@ int simple_archiver_write_v2(FILE *out_f, SDArchiverState *state,
       return SDAS_INTERNAL_ERROR;
     }
     free(ptrs);
-    if (current_size > 0 && current_count > 0) {
+    if ((chunk_counts->count == 0 || current_size > 0) && current_count > 0) {
       uint64_t *count = malloc(sizeof(uint64_t));
       *count = current_count;
       simple_archiver_list_add(chunk_counts, count, NULL);