Skip to content

Commit acb361c

Browse files
committed
Fix dead code branch by checking artifact starting with cname early
1 parent bd34f4c commit acb361c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/gardenlinux/s3/s3_artifacts.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,14 @@ def upload_from_directory(
193193
}
194194

195195
for artifact in artifacts_dir.iterdir():
196-
if not artifact.match(f"{cname}*"):
196+
if not artifact.is_file():
197197
continue
198198

199+
if not not artifact.name.startswith(cname):
200+
raise RuntimeError(
201+
f"Artifact name '{artifact.name}' does not start with cname '{cname}'"
202+
)
203+
199204
s3_key = f"objects/{cname}/{artifact.name}"
200205

201206
with artifact.open("rb") as fp:
@@ -204,10 +209,6 @@ def upload_from_directory(
204209

205210
if artifact.name.startswith(cname):
206211
suffix = artifact.name[len(cname) :]
207-
else:
208-
raise RuntimeError(
209-
f"Artifact name '{artifact.name}' does not start with cname '{cname}'"
210-
)
211212

212213
artifact_metadata = {
213214
"name": artifact.name,

0 commit comments

Comments
 (0)