Changeset - 05b59c48556f
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 15 years ago 2011-01-16 12:27:44
marcin@python-works.com
fixed error when trying to make download on empty repository
3 files changed with 21 insertions and 17 deletions:
0 comments (0 inline, 0 general)
docs/changelog.rst
Show inline comments
 
@@ -18,25 +18,25 @@ news
 
- anonymous repository can be cloned without having to pass default:default
 
  into clone url
 
- fixed #90 whoosh indexer can index chooses repositories passed in command 
 
  line
 
- added dynamic download links in summary. With quick branch/tag selection
 

	
 
fixes
 
-----
 

	
 
- fixed file browser bug, when switching into given form revision the url was 
 
  not changing
 
- fixed propagation to error controller on simplehg and simplegit middlewares
 

	
 
- fixed error when trying to make a download on empty repository
 

	
 

	
 
1.1.2 (**2011-01-12**)
 
======================
 

	
 
news
 
----
 

	
 

	
 
fixes
 
-----
 

	
rhodecode/controllers/files.py
Show inline comments
 
@@ -145,43 +145,45 @@ class FilesController(BaseController):
 
        c.file_history = self._get_history(c.repo, c.file, f_path)
 

	
 
        c.f_path = f_path
 

	
 
        return render('files/files_annotate.html')
 

	
 
    def archivefile(self, repo_name, fname):
 
        archive_specs = {
 
          '.tar.bz2': ('application/x-tar', 'tbz2'),
 
          '.tar.gz': ('application/x-tar', 'tgz'),
 
          '.zip': ('application/zip', 'zip'),
 
        }
 
        
 

	
 
        fileformat = None
 
        revision = None
 
        
 

	
 
        for ext in archive_specs.keys():
 
            archive_spec = fname.split(ext)
 
            if len(archive_spec) == 2:
 
                fileformat = archive_spec[1] or ext
 
                revision = archive_spec[0]
 
        
 

	
 
        if not archive_specs.has_key(fileformat):
 
            return _('Unknown archive type')
 

	
 
        repo = ScmModel().get_repo(repo_name)
 

	
 
        try:
 
            repo.get_changeset(revision)
 
        except ChangesetDoesNotExistError:
 
            return _('Unknown revision %s') % revision
 
        except EmptyRepositoryError:
 
            return _('Empty repository')
 

	
 
        archive = tempfile.TemporaryFile()
 
        localrepo = repo.repo
 
        fname = '%s-%s%s' % (repo_name, revision, fileformat)
 
        archival.archive(localrepo, archive, revision, archive_specs[fileformat][1],
 
                         prefix='%s-%s' % (repo_name, revision))
 
        response.content_type = archive_specs[fileformat][0]
 
        response.content_disposition = 'attachment; filename=%s' % fname
 
        archive.seek(0)
 

	
 
        def read_in_chunks(file_object, chunk_size=1024 * 40):
 
            """Lazy function (generator) to read a file piece by piece.
rhodecode/templates/summary/summary.html
Show inline comments
 
@@ -119,35 +119,38 @@
 
			      <label>${_('Trending source files')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			    <div id="lang_stats"></div> 			   
 
			  </div>
 
			 </div>
 
			 			
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Download')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
		        
 
		        ${h.select('download_options',c.repo_info.get_changeset().raw_id,c.download_options)}
 
		        %for cnt,archive in enumerate(c.repo_info._get_archives()):
 
		             %if cnt >=1:
 
		             |
 
		             %endif
 
		             <span class="tooltip" title="${_('Download %s as %s') %('tip',archive['type'])}" 
 
		                  id="${archive['type']+'_link'}">${h.link_to(archive['type'],
 
		                h.url('files_archive_home',repo_name=c.repo_info.name,
 
		                fname='tip'+archive['extension']),class_="archive_icon")}</span>
 
		        %endfor
 
		        %if len(c.repo_info.revisions) == 0:
 
		          ${_('There are no downloads yet')}
 
		        %else:
 
			        ${h.select('download_options',c.repo_info.get_changeset().raw_id,c.download_options)}
 
			        %for cnt,archive in enumerate(c.repo_info._get_archives()):
 
			             %if cnt >=1:
 
			             |
 
			             %endif
 
			             <span class="tooltip" title="${_('Download %s as %s') %('tip',archive['type'])}" 
 
			                  id="${archive['type']+'_link'}">${h.link_to(archive['type'],
 
			                h.url('files_archive_home',repo_name=c.repo_info.name,
 
			                fname='tip'+archive['extension']),class_="archive_icon")}</span>
 
			        %endfor
 
			    %endif
 
			  </div>
 
			 </div>
 
			 
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Feeds')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
	            ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.repo_info.name),class_='rss_icon')}
 
	            ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.repo_info.name),class_='atom_icon')}
 
			  </div>
 
			 </div>				 			 			 
 
@@ -259,30 +262,29 @@
 
             })
 
             	
 
  	</script>    				
 
</div>
 
        
 
<div class="box box-right"  style="min-height:455px">
 
    <!-- box / title -->
 
    <div class="title">
 
        <h5>${_('Commit activity by day / author')}</h5>
 
    </div>
 
    
 
    <div class="table">
 
        
 
         %if c.no_data:
 
           <div style="padding:0 10px 10px 15px;font-size: 1.2em;">${c.no_data_msg}
 
           %if h.HasPermissionAll('hg.admin')('enable stats on from summary'):
 
                [${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name))}]
 
           %endif
 
           %endif         
 
           </div>
 
        %endif:  
 
        <div id="commit_history" style="width:460px;height:300px;float:left"></div>
 
        <div style="clear: both;height: 10px"></div>
 
        <div id="overview" style="width:460px;height:100px;float:left"></div>
 
        
 
    	<div id="legend_data" style="clear:both;margin-top:10px;">
 
	    	<div id="legend_container"></div>
 
	    	<div id="legend_choices">
 
				<table id="legend_choices_tables" style="font-size:smaller;color:#545454"></table>
 
	    	</div>
 
    	</div>
0 comments (0 inline, 0 general)