diff --git a/app/views/platforms/product_build_lists/_results.html.haml b/app/views/platforms/product_build_lists/_results.html.haml index 228bfc64d..94129618c 100644 --- a/app/views/platforms/product_build_lists/_results.html.haml +++ b/app/views/platforms/product_build_lists/_results.html.haml @@ -13,7 +13,7 @@ %tr - sha1 = item['sha1'] - filename = item['file_name'] - - url = "#{APP_CONFIG['file_store_url']}/#{sha1}" + - url = "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{sha1}" - url << '.log?show=true' if filename =~ /.*\.(log|txt)$/ %td= link_to filename, url %td= sha1 diff --git a/bin/file-store.rb b/bin/file-store.rb index 390121568..c491c9394 100755 --- a/bin/file-store.rb +++ b/bin/file-store.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# argv[0] user token; argv[1] url to file-store require 'json' require 'rest-client' @@ -9,8 +10,7 @@ old_sources = if File.exist? abf_yml [] end #MAX_SIZE = 2 * 1024 * 1024 # 2.megabytes -url = 'http://file-store.rosalinux.ru/api/v1/file_stores.json' -#url = 'http://localhost:3001/api/v1/file_stores.json' +url = "#{ARGF.argv[1]}/api/v1" rclient = RestClient::Resource.new(url, :user => ARGF.argv[0]) # user auth token Dir.glob("*.{bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,xz,lzma}").uniq.sort.each do |file| @@ -18,7 +18,7 @@ Dir.glob("*.{bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,xz,lzma}").uniq.sort.each do |file #next if File.size(file) < MAX_SIZE sha1 = Digest::SHA1.file(file).hexdigest - resp = JSON(RestClient.get url, :params => {:hash => sha1}) + resp = JSON(RestClient.get "#{url}/file_stores", :params => {:hash => sha1}) if resp[0].respond_to?('[]') && resp[0]['file_name'] && resp[0]['sha1_hash'] # file already exists at file-store new_sources << " \"#{file}\": #{sha1}" @@ -26,7 +26,7 @@ Dir.glob("*.{bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,xz,lzma}").uniq.sort.each do |file puts " file \"#{file}\" already exists in the file-store" elsif resp == [] # try to put file at file-store - resp = JSON `curl --user #{ARGF.argv[0]}: -POST -F "file_store[file]=@#{file}" http://file-store.rosalinux.ru/api/v1/upload` + resp = JSON `curl --user #{ARGF.argv[0]}: -POST -F "file_store[file]=@#{file}" #{url}/upload` unless resp['sha1_hash'].nil? new_sources << " \"#{file}\": #{sha1}" FileUtils.rm_rf file diff --git a/bin/import_srpm.sh b/bin/import_srpm.sh index 9665678c8..714813cb6 100755 --- a/bin/import_srpm.sh +++ b/bin/import_srpm.sh @@ -6,6 +6,7 @@ git_path=$2 git_branch=$3 script=$4 token=$5 +file_store_url=$6 name=$(rpm -q --qf '[%{Name}]' -p $srpm_path) version=$(rpm -q --qf '[%{Version}-%{Release}]' -p $srpm_path) tmp_dir=/tmp/$name-$version-$RANDOM @@ -32,7 +33,7 @@ cpio -idv < srpm.cpio rm -f srpm.cpio # Remove archives -$script $token +$script $token $file_store_url # Commit and push changes git add -A . diff --git a/lib/abf_worker/rpm_worker_observer.rb b/lib/abf_worker/rpm_worker_observer.rb index 16f886b41..a8da38f21 100644 --- a/lib/abf_worker/rpm_worker_observer.rb +++ b/lib/abf_worker/rpm_worker_observer.rb @@ -53,7 +53,7 @@ module AbfWorker select{ |r| r['file_name'] !~ /.*\.log$/ }.first sha1 = container ? container['sha1'] : nil if sha1 - bl.container_path = "#{APP_CONFIG['file_store_url']}/#{sha1}" + bl.container_path = "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{sha1}" bl.save! end update_results(bl, options) diff --git a/lib/modules/models/git.rb b/lib/modules/models/git.rb index 44f00c648..a01570247 100644 --- a/lib/modules/models/git.rb +++ b/lib/modules/models/git.rb @@ -93,7 +93,8 @@ module Modules def import_srpm(srpm_path = srpm.path, branch_name = 'import') token = User.find_by_uname('rosa_system').authentication_token - system("#{Rails.root.join('bin', 'import_srpm.sh')} #{srpm_path} #{path} #{branch_name} #{Rails.root.join('bin', 'file-store.rb')} #{token} >> /dev/null 2>&1") + opts = [srpm_path, path, branch_name, Rails.root.join('bin', 'file-store.rb'), token, APP_CONFIG['file_store_url']].join(' ') + system("#{Rails.root.join('bin', 'import_srpm.sh')} #{opts} >> /dev/null 2>&1") end protected