Skip to content

Commit

Permalink
Merge pull request #8679 from rtibbles/no_type_error
Browse files Browse the repository at this point in the history
Check that a channel exists locally before trying to import content
  • Loading branch information
rtibbles committed Nov 17, 2021
2 parents e078b7d + ae615ca commit 25f2a3e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kolibri/core/content/management/commands/importcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ...utils import transfer
from kolibri.core.content.errors import InsufficientStorageSpaceError
from kolibri.core.content.errors import InvalidStorageFilenameError
from kolibri.core.content.models import ChannelMetadata
from kolibri.core.content.models import ContentNode
from kolibri.core.content.utils.file_availability import LocationError
from kolibri.core.content.utils.import_export_content import compare_checksums
Expand Down Expand Up @@ -472,6 +473,16 @@ def _start_file_transfer(self, f, filetransfer):
return FILE_TRANSFERRED, data_transferred

def handle_async(self, *args, **options):
try:
ChannelMetadata.objects.get(id=options["channel_id"])
except ValueError:
raise CommandError(
"{} is not a valid channel_id".format(options["channel_id"])
)
except ChannelMetadata.DoesNotExist:
raise CommandError(
"Must import a channel with importchannel before importing content."
)
if options["command"] == "network":
self.download_content(
options["channel_id"],
Expand Down

0 comments on commit 25f2a3e

Please sign in to comment.