diff --git a/app/models/project.rb b/app/models/project.rb index 967291943..9acb8eaaf 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -209,7 +209,7 @@ class Project < ActiveRecord::Base return nil if resp['sha1_hash'].nil? end if project_tag - project_tag.destroy_file_from_file_store(project_tag.sha1) + project_tag.destroy_files_from_file_store(project_tag.sha1) project_tag.update_attributes(:sha1 => sha1) else project_tags.create( diff --git a/lib/modules/models/file_store_clean.rb b/lib/modules/models/file_store_clean.rb index 06db3fb89..97e86fa69 100644 --- a/lib/modules/models/file_store_clean.rb +++ b/lib/modules/models/file_store_clean.rb @@ -15,21 +15,18 @@ module Modules raise NotImplementedError, "You should implement this method" end - def destroy_files_from_file_store - sha1_of_file_store_files.each do |sha1| - destroy_file_from_file_store sha1 - end - end - - def destroy_file_from_file_store(sha1) + def destroy_files_from_file_store(args = sha1_of_file_store_files) + files = *args token = User.system.find_by_uname('file_store').authentication_token - uri = URI APP_CONFIG['file_store_url'] + uri = URI APP_CONFIG['file_store_url'] Net::HTTP.start(uri.host, uri.port) do |http| - begin - req = Net::HTTP::Delete.new("/api/v1/file_stores/#{sha1}.json") - req.basic_auth token, '' - http.request(req) - rescue # Dont care about it + files.each do |sha1| + begin + req = Net::HTTP::Delete.new("/api/v1/file_stores/#{sha1}.json") + req.basic_auth token, '' + http.request(req) + rescue # Dont care about it + end end end end