Skip to content

Commit

Permalink
fix: wrap call to storage path in NotImplementedError
Browse files Browse the repository at this point in the history
Admin page calls contents.os_path(), and if the storage backend doesn't
support `path`, we can't even load the admin page for that asset.
  • Loading branch information
pomegranited committed Oct 24, 2024
1 parent f65c4c2 commit 4cdbd94
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions openedx_learning/apps/authoring/contents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import annotations

from functools import cache, cached_property
from logging import getLogger

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured, ValidationError
Expand All @@ -19,6 +20,9 @@
from ....lib.managers import WithRelationsManager
from ..publishing.models import LearningPackage


logger = getLogger()

__all__ = [
"MediaType",
"Content",
Expand Down Expand Up @@ -316,8 +320,11 @@ def os_path(self):
This will return ``None`` if there is no backing file (has_file=False).
"""
if self.has_file:
return get_storage().path(self.path)
try:
if self.has_file:
return get_storage().path(self.path)
except NotImplementedError as err:
logger.exception(err)
return None

def read_file(self) -> File:
Expand Down

0 comments on commit 4cdbd94

Please sign in to comment.