Report progress to STDOUT during patch application 38/272238/1
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 8 Mar 2022 10:26:40 +0000 (11:26 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 11 Mar 2022 14:54:26 +0000 (15:54 +0100)
Change-Id: I6c11c85be581c09ce9611421909f293f5e2c924a

bsdiff/ss_brotli_patch.c

index dffad650e6ce9a906ca7b2f121482f675bd8b473..310478cfbc8770ed97dfa2bb2c7023d812d8b9a7 100644 (file)
@@ -38,6 +38,7 @@
 #define BUFF_IN_LEN 4096
 #define BUFF_OUT_LEN 4096
 #define SSINT_LEN 8
+#define BLOCK_COUNT_REPORT 5000
 
 const char SSDIFF_MAGIC[] = "SSDIFF40";
 
@@ -274,6 +275,7 @@ int apply_patch_brotli(char *source_file, size_t source_size, char *dest_file, s
 
     uint64_t total_write = 0;
 
+    uint64_t blocks = 0;
     while (total_write < data.dest_len) {
         /*
          * Make sure we can read the block header
@@ -337,11 +339,17 @@ int apply_patch_brotli(char *source_file, size_t source_size, char *dest_file, s
             write += chunk_size;
         }
         total_write += write;
+
+        blocks++;
+        if (blocks % BLOCK_COUNT_REPORT == 0) {
+            printf("Number of processed patch blocks: %lld\n", blocks);
+        }
     }
 
     result = PF_OK;
 
 exit:
+    printf("Total processed blocks: %lld\n", blocks);
     free_data(&data);
     return result;
 }