From: Norbert Bizet Date: Tue, 12 May 2020 16:44:04 +0000 (+0200) Subject: BEE Backport bacula/src/stored/cloud_parts.c X-Git-Tag: Release-11.3.2~1665 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0109a12d9d1b06f561b00aaba2c27b3e8447be3;p=thirdparty%2Fbacula.git BEE Backport bacula/src/stored/cloud_parts.c This commit is the result of the squash of the following main commits: Author: Norbert Bizet Date: Mon Apr 29 10:07:01 2019 -0400 cloud: compute part hash at upload and download Use GENERATE_CLOUD_HASH to enable it. Not enabled with S3 cloud. Author: Norbert Bizet Date: Wed Oct 12 10:53:12 2016 +0200 Move parts comparison procedures within cloud_parts comparison are dummy unit tested. --- diff --git a/bacula/src/stored/cloud_parts.c b/bacula/src/stored/cloud_parts.c index 313f842064..3ceae34731 100644 --- a/bacula/src/stored/cloud_parts.c +++ b/bacula/src/stored/cloud_parts.c @@ -20,6 +20,7 @@ * Routines for writing Cloud drivers * * Written by Kern Sibbald, May MMXVI + * */ #include "cloud_parts.h" @@ -28,7 +29,9 @@ bool operator==(const cloud_part& lhs, const cloud_part& rhs) { return (lhs.index == rhs.index && lhs.mtime == rhs.mtime && - lhs.size == rhs.size); + lhs.size == rhs.size + /*not just yet */ + /*&& (strcmp(reinterpret_cast(lhs.hash64), reinterpret_cast(rhs.hash64)) == 0)*/ ); } bool operator!=(const cloud_part& lhs, const cloud_part& rhs) @@ -162,12 +165,12 @@ cloud_proxy::~cloud_proxy() bool cloud_proxy::set(const char *volume, cloud_part *part) { if (part) { - return set(volume, part->index, part->mtime, part->size); + return set(volume, part->index, part->mtime, part->size, part->hash64); } return false; } -bool cloud_proxy::set(const char *volume, uint32_t index, utime_t mtime, uint64_t size) +bool cloud_proxy::set(const char *volume, uint32_t index, utime_t mtime, uint64_t size, unsigned char* hash64) { if (!volume || index < 1) { return false; @@ -179,7 +182,12 @@ bool cloud_proxy::set(const char *volume, uint32_t index, utime_t mtime, uint64_ part->index = index; part->mtime = mtime; part->size = size; - + if (hash64) { + memcpy(part->hash64, hash64, 64); + } else { + bmemzero(part->hash64, 64); + } + VolHashItem *hitem = (VolHashItem*)m_hash->lookup(const_cast(volume)); if (hitem) { /* when the node already exist, put the cloud_part into the vol list */ /* free the existing part */ @@ -604,4 +612,4 @@ int main (int argc, char *argv[]) } -#endif /* TEST_PROGRAM */ +#endif /* TEST_PROGRAM */ \ No newline at end of file