Skip to content

Commit 58751a8

Browse files
authored
Merge pull request #122 from ligangty/main
Fix: filter out the prodinfo during indexing generation
2 parents e54374c + 65c7932 commit 58751a8

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

charon/pkgs/indexing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from charon.config import get_template
1717
from charon.storage import S3Client
1818
from charon.constants import (INDEX_HTML_TEMPLATE, NPM_INDEX_HTML_TEMPLATE,
19-
PACKAGE_TYPE_MAVEN, PACKAGE_TYPE_NPM)
19+
PACKAGE_TYPE_MAVEN, PACKAGE_TYPE_NPM, PROD_INFO_SUFFIX)
2020
from jinja2 import Template
2121
import os
2222
import logging
@@ -115,6 +115,8 @@ def __generate_index_html(
115115
bucket_name=bucket,
116116
folder=search_folder
117117
)
118+
# Should filter out the .prodinfo files
119+
contents = [c for c in contents if not c.endswith(PROD_INFO_SUFFIX)]
118120
index = None
119121
if len(contents) == 1 and contents[0].endswith("index.html"):
120122
logger.info("The folder %s only contains index.html, "

tests/test_maven_index.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def test_uploading_index(self):
6161
index_content
6262
)
6363
self.assertIn("<a href=\"../\" title=\"../\">../</a>", index_content)
64+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
6465

6566
indedx_obj = test_bucket.Object(COMMONS_ROOT_INDEX)
6667
index_content = str(indedx_obj.get()["Body"].read(), "utf-8")
@@ -71,6 +72,7 @@ def test_uploading_index(self):
7172
index_content
7273
)
7374
self.assertNotIn("<a href=\"../\" title=\"../\">../</a>", index_content)
75+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
7476

7577
def test_overlap_upload_index(self):
7678
test_zip = os.path.join(os.getcwd(), "tests/input/commons-client-4.5.6.zip")
@@ -99,6 +101,7 @@ def test_overlap_upload_index(self):
99101
"<a href=\"maven-metadata.xml\" title=\"maven-metadata.xml\">maven-metadata.xml</a>",
100102
index_content)
101103
self.assertIn("<a href=\"../\" title=\"../\">../</a>", index_content)
104+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
102105

103106
indedx_obj = test_bucket.Object(COMMONS_LOGGING_INDEX)
104107
index_content = str(indedx_obj.get()["Body"].read(), "utf-8")
@@ -107,6 +110,7 @@ def test_overlap_upload_index(self):
107110
"<a href=\"maven-metadata.xml\" title=\"maven-metadata.xml\">maven-metadata.xml</a>",
108111
index_content)
109112
self.assertIn("<a href=\"../\" title=\"../\">../</a>", index_content)
113+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
110114

111115
indedx_obj = test_bucket.Object(COMMONS_ROOT_INDEX)
112116
index_content = str(indedx_obj.get()["Body"].read(), "utf-8")
@@ -117,6 +121,7 @@ def test_overlap_upload_index(self):
117121
index_content
118122
)
119123
self.assertNotIn("<a href=\"../\" title=\"../\">../</a>", index_content)
124+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
120125

121126
def test_upload_index_with_short_prefix(self):
122127
self.__test_upload_index_with_prefix(SHORT_TEST_PREFIX)
@@ -165,6 +170,7 @@ def __test_upload_index_with_prefix(self, prefix: str):
165170
index_content
166171
)
167172
self.assertIn("<a href=\"../\" title=\"../\">../</a>", index_content)
173+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
168174

169175
indedx_obj = test_bucket.Object(os.path.join(prefix_, COMMONS_ROOT_INDEX))
170176
index_content = str(indedx_obj.get()["Body"].read(), "utf-8")
@@ -175,6 +181,7 @@ def __test_upload_index_with_prefix(self, prefix: str):
175181
index_content
176182
)
177183
self.assertNotIn("<a href=\"../\" title=\"../\">../</a>", index_content)
184+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
178185

179186
def test_deletion_index(self):
180187
self.__prepare_content()
@@ -214,6 +221,7 @@ def test_deletion_index(self):
214221
"<a href=\"maven-metadata.xml\" title=\"maven-metadata.xml\">maven-metadata.xml</a>",
215222
index_content)
216223
self.assertNotIn("<a href=\"4.5.6/\" title=\"4.5.6/\">4.5.6/</a>", index_content)
224+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
217225

218226
indedx_obj = test_bucket.Object(COMMONS_ROOT_INDEX)
219227
index_content = str(indedx_obj.get()["Body"].read(), "utf-8")
@@ -224,6 +232,7 @@ def test_deletion_index(self):
224232
index_content
225233
)
226234
self.assertNotIn("<a href=\"../\" title=\"../\">../</a>", index_content)
235+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
227236

228237
product_459 = "commons-client-4.5.9"
229238
test_zip = os.path.join(os.getcwd(), "tests/input/commons-client-4.5.9.zip")
@@ -282,6 +291,7 @@ def __test_deletion_index_with_prefix(self, prefix: str):
282291
"<a href=\"maven-metadata.xml\" title=\"maven-metadata.xml\">maven-metadata.xml</a>",
283292
index_content)
284293
self.assertNotIn("<a href=\"4.5.6/\" title=\"4.5.6/\">4.5.6/</a>", index_content)
294+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
285295

286296
indedx_obj = test_bucket.Object(os.path.join(prefix_, COMMONS_ROOT_INDEX))
287297
index_content = str(indedx_obj.get()["Body"].read(), "utf-8")
@@ -292,6 +302,7 @@ def __test_deletion_index_with_prefix(self, prefix: str):
292302
index_content
293303
)
294304
self.assertNotIn("<a href=\"../\" title=\"../\">../</a>", index_content)
305+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
295306

296307
test_zip = os.path.join(os.getcwd(), "tests/input/commons-client-4.5.9.zip")
297308
handle_maven_del(

tests/test_npm_index.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ def __test_upload_prefix(self, prefix: str = None):
7878
self.assertIn("<a href=\"code-frame/\" title=\"code-frame/\">code-frame/</a>",
7979
index_content)
8080
self.assertIn("<a href=\"../index.html\" title=\"../\">../</a>", index_content)
81+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
8182

8283
indedx_obj = test_bucket.Object(PREFIXED_ROOT_INDEX)
8384
index_content = str(indedx_obj.get()["Body"].read(), "utf-8")
8485
self.assertIn("<a href=\"@babel/index.html\" title=\"@babel/\">@babel/</a>", index_content)
8586
self.assertNotIn("<a href=\"../index.html\" title=\"../\">../</a>", index_content)
87+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
8688

8789
def test_overlap_upload_index(self):
8890
self.__prepare_content()
@@ -103,6 +105,7 @@ def test_overlap_upload_index(self):
103105
self.assertIn("<a href=\"code-frame/\" title=\"code-frame/\">code-frame/</a>",
104106
index_content)
105107
self.assertIn("<a href=\"../index.html\" title=\"../\">../</a>", index_content)
108+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
106109

107110
def test_deletion_index(self):
108111
self.__test_deletion_prefix()
@@ -149,6 +152,7 @@ def __test_deletion_prefix(self, prefix: str = None):
149152
self.assertIn("<a href=\"code-frame/\" title=\"code-frame/\">code-frame/</a>",
150153
index_content)
151154
self.assertIn("<a href=\"../index.html\" title=\"../\">../</a>", index_content)
155+
self.assertNotIn(PROD_INFO_SUFFIX, index_content)
152156

153157
product_7_15_8 = "code-frame-7.15.8"
154158
test_tgz = os.path.join(os.getcwd(), "tests/input/code-frame-7.15.8.tgz")

0 commit comments

Comments
 (0)