0
0
mirror of https://github.com/django/django.git synced 2024-11-29 22:56:46 +01:00

Explicitly close a file in the collectstatic management command.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16525 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor 2011-07-08 09:39:56 +00:00
parent 68d18b8492
commit 319b0cfb83

View File

@ -1,3 +1,5 @@
from __future__ import with_statement
import os
import sys
from optparse import make_option
@ -9,6 +11,7 @@ from django.utils.encoding import smart_str, smart_unicode
from django.contrib.staticfiles import finders
class Command(NoArgsCommand):
"""
Command that allows to copy or symlink media files from different
@ -236,7 +239,7 @@ Type 'yes' to continue, or 'no' to cancel: """
os.makedirs(os.path.dirname(full_path))
except OSError:
pass
source_file = source_storage.open(path)
self.storage.save(prefixed_path, source_file)
with source_storage.open(path) as source_file:
self.storage.save(prefixed_path, source_file)
if not prefixed_path in self.copied_files:
self.copied_files.append(prefixed_path)