Merge ~jugmac00/launchpad:fix-regresssion-in-oval-data-publishing into launchpad:master

Proposed by Jürgen Gmach
Status: Merged
Approved by: Jürgen Gmach
Approved revision: b1e25d9470b392e0e434bcfa4b1fe7beddfa89ad
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~jugmac00/launchpad:fix-regresssion-in-oval-data-publishing
Merge into: launchpad:master
Diff against target: 79 lines (+49/-3)
2 files modified
lib/lp/archivepublisher/scripts/publishdistro.py (+5/-3)
lib/lp/archivepublisher/tests/test_publishdistro.py (+44/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+441821@code.launchpad.net

Commit message

Do not try to delete the `by-hash` directory

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/archivepublisher/scripts/publishdistro.py b/lib/lp/archivepublisher/scripts/publishdistro.py
2index 754c0bf..38ee406 100644
3--- a/lib/lp/archivepublisher/scripts/publishdistro.py
4+++ b/lib/lp/archivepublisher/scripts/publishdistro.py
5@@ -424,9 +424,11 @@ class PublishDistro(PublisherScript):
6 )
7 return False
8
9- def synchronizeSecondDirectoryWithFirst(self, first_dir, second_dir):
10+ def synchronizeSecondDirectoryWithFirst(
11+ self, first_dir, second_dir, ignore
12+ ):
13 """Synchronize the contents of the second directory with the first."""
14- comparison = dircmp(str(first_dir), str(second_dir))
15+ comparison = dircmp(str(first_dir), str(second_dir), ignore=ignore)
16 files_to_copy = (
17 comparison.diff_files
18 + comparison.left_only
19@@ -464,7 +466,7 @@ class PublishDistro(PublisherScript):
20 )
21 dest_dir.mkdir(parents=True, exist_ok=True)
22 files_modified = self.synchronizeSecondDirectoryWithFirst(
23- staged_oval_data_dir, dest_dir
24+ staged_oval_data_dir, dest_dir, ignore=["by-hash"]
25 )
26 if files_modified:
27 updated = True
28diff --git a/lib/lp/archivepublisher/tests/test_publishdistro.py b/lib/lp/archivepublisher/tests/test_publishdistro.py
29index dba384e..bf36a5e 100644
30--- a/lib/lp/archivepublisher/tests/test_publishdistro.py
31+++ b/lib/lp/archivepublisher/tests/test_publishdistro.py
32@@ -1762,3 +1762,47 @@ class TestPublishDistroMethods(TestCaseWithFactory):
33 ),
34 ]
35 )
36+
37+ def test_syncOVALDataFilesForSuite_skips_by_hash_directory(self):
38+ """`by-hash` directory is generated by the archive indexing machinery
39+
40+ It must not be deleted, so we need to skip it."""
41+ self.setUpOVALDataRsync()
42+ self.useFixture(
43+ MockPatch("lp.archivepublisher.scripts.publishdistro.check_call")
44+ )
45+ archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA)
46+ incoming_dir = (
47+ Path(self.oval_data_root)
48+ / archive.reference
49+ / "breezy-autotest"
50+ / "main"
51+ )
52+ write_file(str(incoming_dir / "test"), b"test")
53+ published_dir = (
54+ Path(getPubConfig(archive).distsroot)
55+ / "breezy-autotest"
56+ / "main"
57+ / "oval"
58+ )
59+ # create oval files and the `by-hash` dir with some test files
60+ write_file(str(published_dir / "foo.oval.xml.bz2"), b"test")
61+ write_file(str(published_dir / "foo2.oval.xml.bz2"), b"test")
62+ by_hash_dir = published_dir / "by-hash"
63+ by_hash_dir.mkdir()
64+ (by_hash_dir / "a").touch()
65+ (by_hash_dir / "b").touch()
66+
67+ script = self.makeScript()
68+ script.txn = FakeTransaction()
69+ script.findDistros = FakeMethod([archive.distribution])
70+ script.getTargetArchives = FakeMethod([archive])
71+ publisher = FakePublisher()
72+ script.getPublisher = FakeMethod(publisher)
73+
74+ script.main()
75+
76+ # `by-hash` still exists and is indeed a directory
77+ self.assertTrue(by_hash_dir.is_dir())
78+ # and still contains the two test files
79+ self.assertEqual(2, len(list(by_hash_dir.iterdir())))

Subscribers

People subscribed via source and target branches

to status/vote changes: