Skip to content

dird: fix expected file count error during bsr build #1511

Merged
BareosBot merged 11 commits intobareos:masterfrom
sebsura:dev/ssura/master/fix-counting-error
Aug 10, 2023
Merged

dird: fix expected file count error during bsr build #1511
BareosBot merged 11 commits intobareos:masterfrom
sebsura:dev/ssura/master/fix-counting-error

Conversation

@sebsura
Copy link
Contributor

@sebsura sebsura commented Jul 14, 2023

Thank you for contributing to the Bareos Project!

We decrement the expected file count counter incorrectly! We should only do so if the last file we selected for restore is split over two volumes; not just whether the last file on the volume is split.
File Indices are not unique between jobs so we have to ensure that we only ever compare the file indices of the same job as well.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
    - Check backport line
    - Required backport PRs have been created
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
    - Required documentation changes are present and part of the PR
Tests
  • Decision taken that a test is required (if not, then remove this paragraph)
  • The choice of the type of test (unit test or systemtest) is reasonable
  • Testname matches exactly what is being tested
  • On a fail, output of the test leads quickly to the origin of the fault

@sebsura sebsura changed the title fix expected file count error during bsr build dird: fix expected file count error during bsr build Jul 24, 2023
@sebsura sebsura force-pushed the dev/ssura/master/fix-counting-error branch from 3e3436f to 6e249ab Compare July 24, 2023 09:31
@sebsura sebsura added the bugfix label Jul 27, 2023
@sebsura sebsura force-pushed the dev/ssura/master/fix-counting-error branch from f9f8f27 to cf039c8 Compare August 10, 2023 07:51
sebsura and others added 11 commits August 10, 2023 08:35
We should only decrement the expected file counter if a file we are
actually restoring is split over two volumes.  That means we need to
keep track of which FileIndices we actually selected to be restored
instead of just assuming that we are restoring the whole volume.
Testing whether two intervals intersect -- which is what the
conditional is trying to do -- can be easily done with

a <= d && b >= c,

where the intervals are [a, b] and [c, d] with a<=b and c<=d.
It is then easy to check that this is equivalent to

max(a, c) <= min(b, d),

which is what the code now does.
This is done because bsr->VolParams saves them as unsigned anyways.
@BareosBot BareosBot force-pushed the dev/ssura/master/fix-counting-error branch from c440cce to 80788e9 Compare August 10, 2023 08:35
@BareosBot BareosBot merged commit e1e8d22 into bareos:master Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants