From: Michael Vrable Date: Thu, 12 Jun 2008 20:53:25 +0000 (-0700) Subject: Compute checksum of checksums file while it still exists. X-Git-Url: http://git.vrable.net/?p=cumulus.git;a=commitdiff_plain;h=4a4d316953123fbb7c2dd076939fb1ba2a4fc29b 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. --- 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()); }