Skip to content

Commit 049ca11

Browse files
committed
Fix dead code branch by checking artifact starting with cname early
1 parent 5550bba commit 049ca11

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/gardenlinux/s3/s3_artifacts.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,18 @@ def upload_from_directory(
196196
if not artifact.match(f"{cname}*"):
197197
continue
198198

199+
if 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:
202207
md5sum = file_digest(fp, "md5").hexdigest()
203208
sha256sum = file_digest(fp, "sha256").hexdigest()
204209

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

212212
artifact_metadata = {
213213
"name": artifact.name,

0 commit comments

Comments
 (0)