Skip to content

Commit

Permalink
[webui] fix long standing bug.
Browse files Browse the repository at this point in the history
You can see it when following the "show latest" link on
https://build.opensuse.org/package/view_file?file=icecream.spec&package=icecream&project=home%3Acoolo&rev=557333bce1ba55e8dad7161376fb2dde

(which is btw absurd as 557333 _is_ the latest, but that's just
nice to have)
  • Loading branch information
coolo committed Mar 27, 2012
1 parent 05a95c6 commit 31426e3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/webui/app/controllers/package_controller.rb
Expand Up @@ -772,10 +772,11 @@ def view_file
redirect_back_or_to :action => :files, :project => @project, :package => @package and return
end
@rev = params[:rev]
@expand = params[:expand]
@addeditlink = false
if @package.can_edit?( session[:login] )
begin
files = @package.files(@rev, params[:expand])
files = @package.files(@rev, @expand)
rescue ActiveXML::Transport::Error => e
files = []
end
Expand All @@ -787,7 +788,7 @@ def view_file
end
end
begin
@file = frontend.get_source(:project => @project.to_s, :package => @package.to_s, :filename => @filename, :rev => @rev)
@file = frontend.get_source(:project => @project.to_s, :package => @package.to_s, :filename => @filename, :rev => @rev, :expand => @expand)
rescue ActiveXML::Transport::NotFoundError => e
flash[:error] = "File not found: #{@filename}"
redirect_to :action => :files, :package => @package, :project => @project and return
Expand Down
2 changes: 1 addition & 1 deletion src/webui/app/views/package/_files_view.html.erb
Expand Up @@ -17,7 +17,7 @@
<tbody>
<% @files.each do |file| %>
<tr><td>
<%= link_to_if(file[:viewable], nbsp(h(file[:name])), :action => :view_file, :project => @project, :package => @package, :file => file[:name], :rev => file[:srcmd5], :expand => params[:expand] ) %>
<%= link_to_if(file[:viewable], nbsp(h(file[:name])), :action => :view_file, :project => @project, :package => @package, :file => file[:name], :rev => file[:srcmd5], :expand => @expand ) %>
<% if @link && @link.has_add_patch?( file[:name] ) %>
(Added Patch)
<% elsif @link && @link.has_patch?( file[:name] ) %>
Expand Down
2 changes: 1 addition & 1 deletion src/webui/app/views/package/view_file.rhtml
Expand Up @@ -5,7 +5,7 @@

<h3><%= @pagetitle %></h3>
<% if @rev %>
<p>Currently displaying revision <i><%= @rev %></i>, <%= link_to('show latest', :project => @project, :package => @package, :file => @filename) %></p>
<p>Currently displaying revision <i><%= @rev %></i>, <%= link_to('show latest', :project => @project, :package => @package, :file => @filename, :expand => @expand ) %></p>
<% end %>

<p>
Expand Down
6 changes: 4 additions & 2 deletions src/webui/lib/frontend_compat.rb
Expand Up @@ -56,8 +56,10 @@ def get_source( opt={} )
path += "/#{pesc opt[:project]}" if opt[:project]
path += "/#{pesc opt[:package]}" if opt[:project] && opt[:package]
path += "/#{pesc opt[:filename]}" if opt[:filename]
path += "?"
path += "rev=#{esc opt[:rev]}" if opt[:rev]
extra = []
extra << "rev=#{esc opt[:rev]}" if opt[:rev]
extra << "expand=#{opt[:expand]}" if opt[:expand]
path += "?#{extra.join('&')}" if extra.length
logger.debug "--> get_source path: #{path}"

transport.direct_http URI("#{path}")
Expand Down

0 comments on commit 31426e3

Please sign in to comment.