diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 10ca245b0..83694f14e 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -46,14 +46,14 @@ namespace :import do if name = `rpm -q --qf '[%{Name}]' -p #{srpm_file}` and $?.success? and name.present? if clear # simply add project = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id) - repo.projects << project + repo.projects << project rescue nil else # check if project already added if project = repo.projects.find_by_name(name) || repo.projects.by_name(name).first # fallback to speedup print "Found project '#{project.name_with_owner}' in '#{platform.name}/#{repo.name}'." elsif scoped = Project.where(:owner_id => owner.id, :owner_type => owner.class) and project = scoped.find_by_name(name) || scoped.by_name(name).first begin - repo.projects << project + repo.projects << project rescue nil rescue Exception => e print "Add project '#{project.name_with_owner}' to '#{platform.name}/#{repo.name}' FAILED: #{e.message}." else @@ -62,7 +62,7 @@ namespace :import do else description = ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', `rpm -q --qf '[%{Description}]' -p #{srpm_file}`) project = Project.create!(:name => name, :description => description) {|p| p.owner = owner} - repo.projects << project + repo.projects << project rescue nil print "Create project #{project.name_with_owner} in #{platform.name}/#{repo.name} OK." end end