Changeset - 982d8a80e048
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 14 years ago 2012-05-17 01:28:25
marcin@python-works.com
archive file fixes for python 2.5
1 file changed with 7 insertions and 6 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/files.py
Show inline comments
 
@@ -22,7 +22,7 @@
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
from __future__ import with_statement
 
import os
 
import logging
 
import traceback
 
@@ -360,13 +360,14 @@ class FilesController(BaseRepoController
 
        except (ImproperArchiveTypeError, KeyError):
 
            return _('Unknown archive type')
 

	
 
        archive = tempfile.NamedTemporaryFile(mode='w+r+b', delete=False)
 
        cs.fill_archive(stream=archive, kind=fileformat, subrepos=subrepos)
 
        archive.close()
 
        fd, _archive_name = tempfile.mkstemp(suffix='rcarchive')
 
        with open(_archive_name, 'wb') as f:
 
            cs.fill_archive(stream=f, kind=fileformat, subrepos=subrepos)
 

	
 
        response.content_type = content_type
 
        response.content_disposition = 'attachment; filename=%s-%s%s' \
 
            % (repo_name, revision[:12], ext)
 
        response.content_length = str(os.path.getsize(archive.name))
 
        response.content_length = str(os.path.getsize(_archive_name))
 

	
 
        def get_chunked_archive(tmpfile):
 
            while True:
 
@@ -376,7 +377,7 @@ class FilesController(BaseRepoController
 
                    os.unlink(tmpfile.name)
 
                    break
 
                yield data
 
        return get_chunked_archive(tmpfile=open(archive.name,'rb'))
 
        return get_chunked_archive(tmpfile=open(_archive_name, 'rb'))
 

	
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
0 comments (0 inline, 0 general)