From 915a0528eec437e6f820f6fa65b430da91e77fdb Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 17 May 2021 16:42:20 +0200 Subject: [PATCH] Fix org#2427 About incorrect handling of empty files with Accurate=yes on Windows --- bacula/src/filed/verify.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bacula/src/filed/verify.c b/bacula/src/filed/verify.c index 2cebcf457..c2aabf40c 100644 --- a/bacula/src/filed/verify.c +++ b/bacula/src/filed/verify.c @@ -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; -- 2.47.3