From a0b4d38d1984a1d4d6565a8f8522a66bad951c3a Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Mon, 13 May 2019 23:44:08 -0400 Subject: [PATCH] Close version file object using a context manager Signed-off-by: Roberto Rosario --- mayan/apps/documents/models/document_version_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mayan/apps/documents/models/document_version_models.py b/mayan/apps/documents/models/document_version_models.py index 5008ddb0e4..3b1ec1a921 100644 --- a/mayan/apps/documents/models/document_version_models.py +++ b/mayan/apps/documents/models/document_version_models.py @@ -329,8 +329,8 @@ class DocumentVersion(models.Model): Save a copy of the document from the document storage backend to the local filesystem """ - input_file_object = self.open() - shutil.copyfileobj(fsrc=input_file_object, fdst=file_object) + with self.open() as input_file_object: + shutil.copyfileobj(fsrc=input_file_object, fdst=file_object) @property def size(self):