#907: remove #destroy_file_from_file_store method, refactoring
This commit is contained in:
parent
7bcbe39e61
commit
a82167fe4c
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue