Refactoring of Project#get_project_tag_sha1
This commit is contained in:
parent
518c87994c
commit
6cea19d720
|
@ -244,16 +244,9 @@ class Project < ActiveRecord::Base
|
|||
return project_tag.sha1 if project_tag && project_tag.commit_id == tag.commit.id && FileStoreClean.file_exist_on_file_store?(project_tag.sha1)
|
||||
|
||||
archive = archive_by_treeish_and_format tag.name, format
|
||||
sha1 = Digest::SHA1.file(archive[:path]).hexdigest
|
||||
unless FileStoreClean.file_exist_on_file_store? sha1
|
||||
token = User.find_by(uname: 'rosa_system').authentication_token
|
||||
begin
|
||||
resp = JSON `curl --user #{token}: -POST -F 'file_store[file]=@#{archive[:path]};filename=#{name}-#{tag.name}.#{tag_file_format(format)}' #{APP_CONFIG['file_store_url']}/api/v1/upload`
|
||||
rescue # Dont care about it
|
||||
resp = {}
|
||||
end
|
||||
return nil if resp['sha1_hash'].nil?
|
||||
end
|
||||
sha1 = FileStoreClean.save_file_to_file_store(archive)
|
||||
return nil in sha1.blank?
|
||||
|
||||
if project_tag
|
||||
project_tag.destroy_files_from_file_store(project_tag.sha1)
|
||||
project_tag.update_attributes(sha1: sha1)
|
||||
|
|
Loading…
Reference in New Issue