diff --git a/app/models/project.rb b/app/models/project.rb index d9b476b8e..2be394c49 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -216,9 +216,8 @@ class Project < ActiveRecord::Base system "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" end if project_tag - old_sha1 = project_tag.sha1 + project_tag.remove_archive_from_file_store(project_tag.sha1) project_tag.update_attributes(:sha1 => sha1) - system "curl --user #{token}: -X DELETE #{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{old_sha1}.json" else project_tags.create( :tag_name => tag.name, diff --git a/app/models/project_tag.rb b/app/models/project_tag.rb index eeb8f1656..bfd6d47f2 100644 --- a/app/models/project_tag.rb +++ b/app/models/project_tag.rb @@ -16,4 +16,12 @@ class ProjectTag < ActiveRecord::Base :tag_name, :format_id + after_destroy :remove_archive_from_file_store + + def remove_archive_from_file_store(sha = sha1) + token = User.find_by_uname('rosa_system').authentication_token + system "curl --user #{token}: -X DELETE #{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{sha}.json" + end + later :remove_archive_from_file_store, :queue => :clone_build + end