The repserver has already some code to find out if a repo is published already
or not.
We could extend that and tell you already, if a package has been published or not.
So we could avoid this additional traffic and IMHO also possible area of bugs.
What do you think about that ?
bye
adrian
Am Mittwoch, 14. April 2010 14:26:15 schrieben Sie:
> From: Thomas Schmidt <tschmidt(a)suse.de>
>
> ---
> src/webui/app/controllers/package_controller.rb | 35 ++++++++++-----------
> src/webui/app/views/project/repositories.html.erb | 2 +-
> 2 files changed, 18 insertions(+), 19 deletions(-)
>
> diff --git a/src/webui/app/controllers/package_controller.rb b/src/webui/app/controllers/package_controller.rb
> index 105885f..54a3452 100644
> --- a/src/webui/app/controllers/package_controller.rb
> +++ b/src/webui/app/controllers/package_controller.rb
> @@ -33,7 +33,6 @@ class PackageController < ApplicationController
> elsif @project.bugowner
> @bugowner_mail = Person.find_cached( @project.bugowner ).email.to_s
> end
> -
> fill_status_cache
> end
>
> @@ -44,7 +43,7 @@ class PackageController < ApplicationController
> @dproject = params[:dproject]
> @filename = params[:filename]
> @fileinfo = Fileinfo.find_cached( :project => params[:dproject], :package => '_repository', :repository => params[:drepository], :arch => @arch,
> - :filename => params[:dname], :view => 'fileinfo_ext')
> + :filename => params[:dname], :view => 'fileinfo_ext')
> @durl = nil
> end
>
> @@ -53,28 +52,15 @@ class PackageController < ApplicationController
> @repository = params[:repository]
> @filename = params[:filename]
> @fileinfo = Fileinfo.find_cached( :project => @project, :package => @package, :repository => @repository, :arch => @arch,
> - :filename => @filename, :view => 'fileinfo_ext')
> - puts @fileinfo
> + :filename => @filename, :view => 'fileinfo_ext')
> @durl = repo_url( @project, @repository ) + "/#{@fileinfo.arch}/#{@filename}"
> - puts @durl
> - if @durl
> - uri = URI.parse( @durl )
> - response = nil
> - Net::HTTP.start(uri.host, uri.port) do |http|
> - response = http.head uri.path
> - end
> - @durl = nil if response.code.to_i >= 400
> - else
> - logger.debug "no repository url"
> - end
> - if @user and not @durl
> - # use API for logged in users if the mirror is not available
> + if !file_available?( @durl ) and @user
> + # only use API for logged in users if the mirror is not available
> @durl = rpm_url( @project, @package, @repository, @arch, @filename )
> end
> end
>
> def binaries
> -
> @repository = params[:repository]
> @buildresult = Buildresult.find( :project => @project, :package => @package,
> :repository => @repository, :view => ['binarylist', 'status'] )
> @@ -835,6 +821,19 @@ class PackageController < ApplicationController
>
> private
>
> + def file_available? url, max_redirects=5
> + uri = URI.parse( url )
> + Net::HTTP.start(uri.host, uri.port) do |http|
> + logger.debug "Checking url: #{url}"
> + response = http.head uri.path
> + if response.code.to_i == 302 and response['location'] and max_redirects > 0
> + return file_available? response['location'], (max_redirects - 1)
> + end
> + response.code.to_i == 200 ? true : false
> + end
> + end
> +
> +
> def get_files( project, package )
> # files whose name ends in the following extensions should not be editable
> no_edit_ext = %w{ .bz2 .dll .exe .gem .gif .gz .jar .jpeg .jpg .lzma .ogg .pdf .pk3 .png .ps .rpm .svgz .tar .taz .tb2 .tbz .tbz2 .tgz .tlz .txz .xpm .xz .z .zip }
> diff --git a/src/webui/app/views/project/repositories.html.erb b/src/webui/app/views/project/repositories.html.erb
> index 615c395..00dbb55 100644
> --- a/src/webui/app/views/project/repositories.html.erb
> +++ b/src/webui/app/views/project/repositories.html.erb
> @@ -1,7 +1,7 @@
> <%
> @crumb_list = [
> link_to( 'Projects', :action => :list_public),
> - link_to( @project.name, :action => :show, :project => @project.name ), "Repositories"
> + link_to( @project, :action => :show, :project => @project ), "Repositories"
> ]
> -%>
>
>
--
Adrian Schroeter
SUSE Linux Products GmbH
email: adrian(a)suse.de
--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe(a)opensuse.org
For additional commands, e-mail: opensuse-buildservice+help(a)opensuse.org