Skip to content
Snippets Groups Projects

Fix #1015: broken migration on S3

Merged Agate requested to merge 1015-fix-migration-error into develop
1 file
+ 1
1
Compare changes
  • Side-by-side
  • Inline
@@ -19,13 +19,13 @@ def create_attachments(apps, schema_editor):
@@ -19,13 +19,13 @@ def create_attachments(apps, schema_editor):
print('Creating attachments for {} user avatars, this may take a while…'.format(total))
print('Creating attachments for {} user avatars, this may take a while…'.format(total))
from django.core.files.storage import FileSystemStorage
from django.core.files.storage import FileSystemStorage
for i, user in enumerate(qs):
for i, user in enumerate(qs):
 
size = None
if isinstance(user.avatar.storage._wrapped, FileSystemStorage):
if isinstance(user.avatar.storage._wrapped, FileSystemStorage):
try:
try:
size = user.avatar.size
size = user.avatar.size
except FileNotFoundError:
except FileNotFoundError:
# can occur when file isn't found on disk or S3
# can occur when file isn't found on disk or S3
print(" Warning: avatar file wasn't found in storage: {}".format(e.__class__))
print(" Warning: avatar file wasn't found in storage: {}".format(e.__class__))
size = None
obj_attachment_mapping[user.actor] = Attachment(
obj_attachment_mapping[user.actor] = Attachment(
file=user.avatar,
file=user.avatar,
size=size,
size=size,
Loading