Skip to content

Commit

Permalink
Fix "ValueError: I/O operation on closed file" with S3
Browse files Browse the repository at this point in the history
in django-storages==1.6.5, te S3Boto3Storage backend closes the file
after saving. This effectively prevents from re-opening the same file
later.

Bug: jschneier/django-storages#382
Resolution: jschneier/django-storages#754
  • Loading branch information
regisb committed Nov 2, 2020
1 parent 2ffb351 commit b49aff9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion openedxscorm/scormxblock.py
Expand Up @@ -221,8 +221,10 @@ def studio_submit(self, request, _suffix):
self.clean_storage()

# Then, extract zip file
# At this point we can no longer use the package_file object because some storage backends close the file after
# saving. So we need to re-open the file, this time from the storage backend.
try:
self.extract_package(package_file)
self.extract_package(self.storage.open(self.package_path))
self.update_package_fields()
except ScormError as e:
response["errors"].append(e.args[0])
Expand Down

0 comments on commit b49aff9

Please sign in to comment.