From 6cea19d72088bdc7f283994c43e60cdfa7fe6e3c Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 5 May 2014 19:26:03 +0400 Subject: [PATCH] Refactoring of Project#get_project_tag_sha1 --- app/models/project.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index b258f3ba3..883743efe 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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)