fix: check if its file before fetching

This commit is contained in:
Jannat Patel
2024-12-06 15:14:03 +05:30
parent 726ae8ac06
commit 463a1d8c7c

View File

@@ -154,9 +154,11 @@ class SCORMRenderer(BaseRenderer):
if not extension:
path = f"{path}.html"
f = open(path, "rb")
response = Response(
wrap_file(frappe.local.request.environ, f), direct_passthrough=True
)
response.mimetype = mimetypes.guess_type(path)[0]
return response
# check if path exists and is actually a file and not a folder
if os.path.exists(path) and os.path.isfile(path):
f = open(path, "rb")
response = Response(
wrap_file(frappe.local.request.environ, f), direct_passthrough=True
)
response.mimetype = mimetypes.guess_type(path)[0]
return response