Fix logging percentage in BlobFileWriter.
Should clear number of stored blobs when enable logging.
Bug: 25293923
TEST=Generated a full payload, the percentage is correct.
Change-Id: Ie779d699db1b12105bbf77fbae3a02c41d28401b
diff --git a/payload_generator/blob_file_writer.cc b/payload_generator/blob_file_writer.cc
index ab57f6f..501df0e 100644
--- a/payload_generator/blob_file_writer.cc
+++ b/payload_generator/blob_file_writer.cc
@@ -41,6 +41,7 @@
void BlobFileWriter::SetTotalBlobs(size_t total_blobs) {
total_blobs_ = total_blobs;
+ stored_blobs_ = 0;
}
} // namespace chromeos_update_engine
diff --git a/payload_generator/blob_file_writer.h b/payload_generator/blob_file_writer.h
index 6ae1a3f..cbc13ae 100644
--- a/payload_generator/blob_file_writer.h
+++ b/payload_generator/blob_file_writer.h
@@ -37,7 +37,8 @@
off_t StoreBlob(const brillo::Blob& blob);
// The number of |total_blobs| is the number of blobs that will be stored but
- // is only used for logging purposes. If not set, logging will be skipped.
+ // is only used for logging purposes. If not set or set to 0, logging will be
+ // skipped. This function will also reset the number of stored blobs to 0.
void SetTotalBlobs(size_t total_blobs);
private:
diff --git a/payload_generator/full_update_generator.cc b/payload_generator/full_update_generator.cc
index f9173ef..1ae01b9 100644
--- a/payload_generator/full_update_generator.cc
+++ b/payload_generator/full_update_generator.cc
@@ -68,12 +68,6 @@
private:
bool ProcessChunk();
- // Stores the operation blob in the |blob_fd_| and updates the
- // |blob_file_size| accordingly.
- // This method is thread-safe since it uses a mutex to access the file.
- // Returns the data offset where the data was written to.
- off_t StoreBlob(const brillo::Blob& blob);
-
// Work parameters.
int fd_;
off_t offset_;
@@ -193,6 +187,10 @@
for (ChunkProcessor& processor : chunk_processors)
thread_pool.AddWork(&processor);
thread_pool.JoinAll();
+
+ // All the work done, disable logging.
+ blob_file->SetTotalBlobs(0);
+
// All the operations must have a type set at this point. Otherwise, a
// ChunkProcessor failed to complete.
for (const AnnotatedOperation& aop : *aops) {