mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-30 01:46:24 +01:00
Move file.open call into set-file-metadata method
If the file is already open this is the same as seek(0), so there are no unwanted side effects from this.
This commit is contained in:
parent
fcb2776383
commit
fe73506747
@ -135,6 +135,8 @@ class AbstractDocument(CollectionMember, index.Indexed, models.Model):
|
||||
return self.file_hash
|
||||
|
||||
def _set_document_file_metadata(self):
|
||||
self.file.open()
|
||||
|
||||
# Set new document file size
|
||||
self.file_size = self.file.size
|
||||
|
||||
|
@ -118,7 +118,6 @@ class CreateFromUploadedDocumentView(BaseCreateFromUploadView):
|
||||
os.path.basename(self.upload.file.name), self.upload.file.file, save=False
|
||||
)
|
||||
self.object.uploaded_by_user = self.request.user
|
||||
self.object.file.open()
|
||||
self.object._set_document_file_metadata()
|
||||
form.save()
|
||||
|
||||
|
@ -237,6 +237,8 @@ class AbstractImage(ImageFileMixin, CollectionMember, index.Indexed, models.Mode
|
||||
return self.file_hash
|
||||
|
||||
def _set_image_file_metadata(self):
|
||||
self.file.open()
|
||||
|
||||
# Set new image file size
|
||||
self.file_size = self.file.size
|
||||
|
||||
|
@ -160,7 +160,6 @@ class CreateFromUploadedImageView(BaseCreateFromUploadView):
|
||||
os.path.basename(self.upload.file.name), self.upload.file.file, save=False
|
||||
)
|
||||
self.object.uploaded_by_user = self.request.user
|
||||
self.object.file.open()
|
||||
self.object._set_image_file_metadata()
|
||||
form.save()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user