Skip to content

Commit

Permalink
Merge pull request #72 from flyingcircusio/PL-133161-distrust-check
Browse files Browse the repository at this point in the history
Fix distrusted check when writing to store
  • Loading branch information
dhnasa authored Dec 4, 2024
2 parents e558a31 + 7d9ac9f commit 34ce151
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions changelog.d/20241118_180122_jb_PL_133161_distrust_check.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. A new scriv changelog fragment.
- Fix check for distrusted revisions when writing to store
12 changes: 12 additions & 0 deletions src/backy/rbd/tests/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ def test_gc(rbdsource, repository, log):
assert len(list(rbdsource.store.ls())) == 0


def test_open_distrusted(rbdsource, repository):
r1 = create_rev(repository, set())
rbdsource.open(r1, "wb")
assert not rbdsource.store.force_writes

r1.distrust()
r1.write_info()
r2 = create_rev(repository, set())
rbdsource.open(r2, "wb")
assert rbdsource.store.force_writes


def test_smoketest_internal(rbdsource, repository, tmp_path, log):
# These copies of data are intended to be different versions of the same
# file.
Expand Down
9 changes: 2 additions & 7 deletions src/backy/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,12 @@ def clean_history(self) -> List[Revision]:

@property
def local_history(self):
"""History without incomplete revisions."""
"""History without remote revisions."""
return self.get_history(local=True)

@property
def contains_distrusted(self) -> bool:
return any(
(
r == Trust.DISTRUSTED
for r in self.get_history(clean=True, local=True)
)
)
return any((r.trust == Trust.DISTRUSTED for r in self.local_history))

def validate_tags(self, tags):
missing_tags = (
Expand Down

0 comments on commit 34ce151

Please sign in to comment.