]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix org#2427 About incorrect handling of empty files with Accurate=yes on Windows
authorEric Bollengier <eric@baculasystems.com>
Mon, 17 May 2021 14:42:20 +0000 (16:42 +0200)
committerEric Bollengier <eric@baculasystems.com>
Wed, 2 Jun 2021 09:35:04 +0000 (11:35 +0200)
bacula/src/filed/verify.c

index 2cebcf45784a9c2bc52f211ac2701d1114cfff0b..c2aabf40c37122065c1cbb9bbd18517d169e14ac 100644 (file)
@@ -288,12 +288,21 @@ good_rtn:
 int digest_file(JCR *jcr, FF_PKT *ff_pkt, DIGEST *digest)
 {
    BFILE bfd;
-
+   bool do_digest = true;
    Dmsg0(50, "=== digest_file\n");
    binit(&bfd);
 
-   if (ff_pkt->statp.st_size > 0 || ff_pkt->type == FT_RAW
-         || ff_pkt->type == FT_FIFO) {
+   /* On Windows, even an empty file has some data to read and compare like the
+    * security stream, while on linux, the empty file is just empty.
+    */
+#ifndef HAVE_WIN32
+   if (ff_pkt->statp.st_size == 0) {
+      do_digest = false;
+   }
+#endif
+
+   if (do_digest || ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO)
+   {
       int noatime = ff_pkt->flags & FO_NOATIME ? O_NOATIME : 0;
       if ((bopen(&bfd, ff_pkt->snap_fname, O_RDONLY | O_BINARY | noatime, 0)) < 0) {
          ff_pkt->ff_errno = errno;