From 4a4d316953123fbb7c2dd076939fb1ba2a4fc29b Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Thu, 12 Jun 2008 13:53:25 -0700 Subject: [PATCH] Compute checksum of checksums file while it still exists. When data is being stored remotely, the checksums file (containing hashes for all the segments needed by a snapshot) may only be stored locally for a short period of time. We can't wait to compute its checksum (for inclusion into the root descriptor) until the time when the root descriptor is writtenout, since the checksum file may be gone by then. Compute the checksum earlier (before sending the checksums file to remote storage), and save the checksum value until it is written out later. --- scandir.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scandir.cc b/scandir.cc index 24e3927..ac013a8 100644 --- a/scandir.cc +++ b/scandir.cc @@ -811,6 +811,14 @@ int main(int argc, char *argv[]) } } fclose(checksums); + + SHA1Checksum checksum_csum; + string csum; + checksum_filename = checksum_file->get_local_path(); + if (checksum_csum.process_file(checksum_filename.c_str())) { + csum = checksum_csum.checksum_str(); + } + checksum_file->send(); db->Close(); @@ -855,9 +863,7 @@ int main(int argc, char *argv[]) fprintf(descriptor, "Backup-Intent: %g\n", snapshot_intent); fprintf(descriptor, "Root: %s\n", backup_root.c_str()); - SHA1Checksum checksum_csum; - if (checksum_csum.process_file(checksum_filename.c_str())) { - string csum = checksum_csum.checksum_str(); + if (csum.size() > 0) { fprintf(descriptor, "Checksums: %s\n", csum.c_str()); } -- 2.20.1