Skip to content

Commit dc11532

Browse files
committed
Fix Layer.lookup_media_type_for_file_name() to match file names as well
Signed-off-by: Tobias Wolf <wolf@b1-systems.de>
1 parent ee84f41 commit dc11532

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/gardenlinux/oci/layer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def generate_metadata_from_file_name(file_name: PathLike | str, arch: str) -> di
159159
@staticmethod
160160
def lookup_media_type_for_file_name(file_name: str) -> str:
161161
"""
162-
Looks up the media type based on file extension.
162+
Looks up the media type based on file name or extension.
163163
164164
:param file_name: File path and name of the target layer
165165
@@ -170,9 +170,9 @@ def lookup_media_type_for_file_name(file_name: str) -> str:
170170
if not isinstance(file_name, PathLike):
171171
file_name = Path(file_name)
172172

173-
for suffix in GL_MEDIA_TYPES:
174-
if file_name.match(f"*.{suffix}"):
175-
return GL_MEDIA_TYPE_LOOKUP[suffix]
173+
for lookup_name in GL_MEDIA_TYPES:
174+
if file_name.match(f"*.{lookup_name}") or str(file_name) == lookup_name:
175+
return GL_MEDIA_TYPE_LOOKUP[lookup_name]
176176

177177
raise ValueError(
178178
f"Media type for {file_name} is not defined. You may want to add the definition to parse_features_lib"

0 commit comments

Comments
 (0)