Commit 5f681af8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix wrong file serve when deploy new maven package build with same version [ci skip]

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 747d901c
......@@ -4,4 +4,6 @@ class Packages::PackageFile < ActiveRecord::Base
validates :package, presence: true
mount_uploader :file, PackageFileUploader
scope :recent, -> { reorder(id: :desc) }
end
module Packages
class CreateMavenPackageService < BaseService
def execute
package = Packages::Package.create(project: project)
package = Packages::Package.create!(
project: project,
name: full_app_name,
version: params[:app_version]
)
Packages::MavenMetadatum.create!(
package: package,
......@@ -10,5 +14,11 @@ module Packages
app_version: params[:app_version]
)
end
private
def full_app_name
params[:app_group] + '/' + params[:app_name]
end
end
end
......@@ -54,7 +54,7 @@ module API
app_name: params[:app_name],
app_version: params[:app_version])
package_file = metadata.package.package_files.find_by!(file_name: file_name)
package_file = metadata.package.package_files.recent.find_by!(file_name: file_name)
case format
when 'md5'
......@@ -96,7 +96,7 @@ module API
if format
# Maven tries to create a md5 and sha1 files for each package file.
# Instead, we update existing package file record with such data.
package_file = metadata.package.package_files.find_by!(file_name: file_name)
package_file = metadata.package.package_files.recent.find_by!(file_name: file_name)
case format
when 'md5'
......@@ -105,6 +105,8 @@ module API
package_file.file_sha1 = string_file
end
else
# TODO: If maven-metadata.xml file is present for this package, we
# need to update it instead of creating a new one
package_file = metadata.package.package_files.new
package_file.file_name = file_name
package_file.file_type = file_name.rpartition('.').last
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment