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.
pull/8804/head
Matt Westcott 2022-07-05 16:41:17 +01:00 zatwierdzone przez Matt Westcott
rodzic fcb2776383
commit fe73506747
4 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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()

Wyświetl plik

@ -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

Wyświetl plik

@ -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()