]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport bacula/src/stored/cloud_parts.c
authorNorbert Bizet <norbert.bizet@baculasystems.com>
Tue, 12 May 2020 16:44:04 +0000 (18:44 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 29 Apr 2021 08:44:18 +0000 (10:44 +0200)
This commit is the result of the squash of the following main commits:

Author: Norbert Bizet <norbert.bizet@baculasystems.com>
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 <norbert.bizet@baculasystems.com>
Date:   Wed Oct 12 10:53:12 2016 +0200

    Move parts comparison procedures within cloud_parts

    comparison are dummy unit tested.

bacula/src/stored/cloud_parts.c

index 313f842064581b9e7973b78ce9b33ffef0ce8ffc..3ceae347311f062cb6db001cb1afac3a43a020a4 100644 (file)
@@ -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<const char*>(lhs.hash64), reinterpret_cast<const char*>(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<char*>(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