Refactoring of Project#get_project_tag_sha1

This commit is contained in:
Vokhmin Alexey V 2014-05-05 19:26:03 +04:00
parent 518c87994c
commit 6cea19d720
1 changed files with 3 additions and 10 deletions

View File

@ -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) 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 archive = archive_by_treeish_and_format tag.name, format
sha1 = Digest::SHA1.file(archive[:path]).hexdigest sha1 = FileStoreClean.save_file_to_file_store(archive)
unless FileStoreClean.file_exist_on_file_store? sha1 return nil in sha1.blank?
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
if project_tag if project_tag
project_tag.destroy_files_from_file_store(project_tag.sha1) project_tag.destroy_files_from_file_store(project_tag.sha1)
project_tag.update_attributes(sha1: sha1) project_tag.update_attributes(sha1: sha1)