[#120] support external downloads storage; remove links for hidden platforms

This commit is contained in:
Alexander Machehin 2013-05-06 23:40:30 +06:00
parent 59d8f5e1dd
commit 632eeb8e5f
5 changed files with 11 additions and 28 deletions

View File

@ -78,9 +78,8 @@ module BuildListsHelper
end
def container_url(full_path = true, build_list = @build_list)
p = ''
p << "http://#{request.host_with_port}" if full_path
p << "/downloads/#{build_list.save_to_platform.name}/container/#{build_list.id}"
p = full_path ? APP_CONFIG['downloads_url'].dup : "http://#{request.host_with_port}/downloads"
p << "/#{build_list.save_to_platform.name}/container/#{build_list.id}"
p << "/#{build_list.arch.name}/#{build_list.save_to_repository.name}/release" if full_path && build_list.build_for_platform.distrib_type == 'mdv'
p.html_safe
end

View File

@ -412,10 +412,10 @@ class BuildList < ActiveRecord::Base
repos |= ['146'] if build_for_platform_id == 376
include_repos_hash = {}.tap do |h|
Repository.where(:id => (repos | (extra_repositories || [])) ).each do |repo|
path = repo.platform.public_downloads_url(nil, arch.name, repo.name)
path = repo.platform.public_downloads_url(arch.name, repo.name)
# path.gsub!(/^http:\/\/(0\.0\.0\.0|localhost)\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production?
# Path looks like:
# http://abf.rosalinux.ru/downloads/rosa-server2012/repository/x86_64/base/
# http://abf-downloads.rosalinux.ru/downloads/rosa-server2012/repository/x86_64/base/
# so, we should append:
# - release
# - updates
@ -425,7 +425,7 @@ class BuildList < ActiveRecord::Base
end
host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host]
BuildList.where(:id => extra_build_lists).each do |bl|
path = "http://#{host}/downloads/#{bl.save_to_platform.name}/container/"
path = "#{APP_CONFIG['downloads_url']}/#{bl.save_to_platform.name}/container/"
path << "#{bl.id}/#{bl.arch.name}/#{bl.save_to_repository.name}/release"
include_repos_hash["container_#{bl.id}"] = path
end

View File

@ -57,20 +57,17 @@ class Platform < ActiveRecord::Base
def urpmi_list(host = nil, pair = nil, add_commands = true, repository_name = 'main')
host ||= default_host
blank_pair = {:login => 'login', :pass => 'password'}
pair = blank_pair if pair.blank?
urpmi_commands = ActiveSupport::OrderedHash.new
# TODO: rename method or create separate methods for mdv and rhel
# Platform.main.opened.where(:distrib_type => APP_CONFIG['distr_types'].first).each do |pl|
Platform.main.opened.each do |pl|
urpmi_commands[pl.name] = {}
local_pair = pl.id != self.id ? blank_pair : pair
head = hidden? ? "http://#{local_pair[:login]}@#{local_pair[:pass]}:#{host}/private/" : "http://#{host}/downloads/"
# FIXME should support restricting access to the hidden platform
Arch.all.each do |arch|
tail = "/#{arch.name}/#{repository_name}/release"
command = add_commands ? "urpmi.addmedia #{name} " : ''
command << "#{head}#{name}/repository/#{pl.name}#{tail}"
command << "#{APP_CONFIG['downloads_url']}#{name}/repository/#{pl.name}#{tail}"
urpmi_commands[pl.name][arch.name] = command
end
end
@ -94,21 +91,8 @@ class Platform < ActiveRecord::Base
Rails.root.join("public", "downloads", name)
end
def prefix_url(pub, options = {})
options[:host] ||= default_host
pub ? "http://#{options[:host]}/downloads" : "http://#{options[:login]}:#{options[:password]}@#{options[:host]}/private"
end
def public_downloads_url(host = nil, arch = nil, repo = nil, suffix = nil)
downloads_url prefix_url(true, :host => host), arch, repo, suffix
end
def private_downloads_url(login, password, host = nil, arch = nil, repo = nil, suffix = nil)
downloads_url prefix_url(false, :host => host, :login => login, :password => password), arch, repo, suffix
end
def downloads_url(prefix, arch = nil, repo = nil, suffix = nil)
"#{prefix}/#{name}/repository/".tap do |url|
def public_downloads_url(arch = nil, repo = nil, suffix = nil)
"#{APP_CONFIG['downloads_url']}/#{name}/repository/".tap do |url|
url << "#{arch}/" if arch.present?
url << "#{repo}/" if repo.present?
url << "#{suffix}/" if suffix.present?

View File

@ -120,7 +120,7 @@ class ProductBuildList < ActiveRecord::Base
end
def container_path
"/downloads/#{product.platform.name}/product/#{id}/"
"#{APP_CONFIG['downloads_url']}/#{product.platform.name}/product/#{id}/"
end
def event_log_message

View File

@ -21,7 +21,7 @@ common: &common
facebook:
id: 'APP_ID'
secret: 'APP_SECRET'
downloads_url: 'http://abf-downloads.rosalinux.ru/'
wiki_formats:
markdown: "Markdown"
textile: "Textile"