Changeset - 8d0858376163
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2011-02-27 03:24:04
marcin@python-works.com
fixed problem with rawfile content_disposition attachment,
webob assumes that file is encoded with iso, and we use utf8 in rhodecode
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/files.py
Show inline comments
 
@@ -115,51 +115,51 @@ class FilesController(BaseRepoController
 
            except RepositoryError, e:
 
                h.flash(str(e), category='warning')
 
                redirect(h.url('files_home', repo_name=repo_name, revision=revision))
 

	
 
        except EmptyRepositoryError, e:
 
            h.flash(_('There are no files yet'), category='warning')
 
            redirect(h.url('summary_home', repo_name=repo_name))
 

	
 
        except RepositoryError, e:
 
            h.flash(str(e), category='warning')
 
            redirect(h.url('files_home', repo_name=repo_name, revision='tip'))
 

	
 

	
 

	
 
        return render('files/files.html')
 

	
 
    def rawfile(self, repo_name, revision, f_path):
 
        cs = self.__get_cs(revision, repo_name)
 
        try:
 
            file_node = cs.get_node(f_path)
 
        except RepositoryError, e:
 
            h.flash(str(e), category='warning')
 
            redirect(h.url('files_home', repo_name=repo_name, revision=cs.raw_id))
 

	
 
        fname = f_path.split('/')[-1].encode('utf8', 'replace')
 
        response.content_type = file_node.mimetype
 
        response.content_disposition = 'attachment; filename=%s' \
 
                                                    % f_path.split('/')[-1]
 
        response.content_disposition = 'attachment; filename=%s' % fname
 
        return file_node.content
 

	
 
    def raw(self, repo_name, revision, f_path):
 
        cs = self.__get_cs(revision, repo_name)
 
        try:
 
            file_node = cs.get_node(f_path)
 
        except RepositoryError, e:
 
            h.flash(str(e), category='warning')
 
            redirect(h.url('files_home', repo_name=repo_name, revision=cs.raw_id))
 

	
 
        response.content_type = 'text/plain'
 

	
 
        return file_node.content
 

	
 
    def annotate(self, repo_name, revision, f_path):
 
        cs = self.__get_cs(revision, repo_name)
 
        try:
 
            c.file = cs.get_node(f_path)
 
        except RepositoryError, e:
 
            h.flash(str(e), category='warning')
 
            redirect(h.url('files_home', repo_name=repo_name, revision=cs.raw_id))
 

	
 
        c.file_history = self._get_history(c.rhodecode_repo, c.file, f_path)
 
        c.cs = cs
0 comments (0 inline, 0 general)