Commit 397f4bda authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'debian_package_file_upload' into 'master'

Use a dynamic segment not depending on the package id for Debian files

See merge request gitlab-org/gitlab!50433
parents 969d192f 8e291c74
...@@ -22,6 +22,8 @@ class Packages::PackageFileUploader < GitlabUploader ...@@ -22,6 +22,8 @@ class Packages::PackageFileUploader < GitlabUploader
def dynamic_segment def dynamic_segment
raise ObjectNotReadyError, "Package model not ready" unless model.id raise ObjectNotReadyError, "Package model not ready" unless model.id
Gitlab::HashedPath.new('packages', model.package.id, 'files', model.id, root_hash: model.package.project_id) package_segment = model.package.debian? ? 'debian' : model.package.id
Gitlab::HashedPath.new('packages', package_segment, 'files', model.id, root_hash: model.package.project_id)
end end
end end
---
title: Use a dynamic segment not depending on the package id for Debian files
merge_request: 50433
author: Mathieu Parent
type: changed
...@@ -2,14 +2,19 @@ ...@@ -2,14 +2,19 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Packages::PackageFileUploader do RSpec.describe Packages::PackageFileUploader do
let(:package_file) { create(:package_file, :xml) } {
package_file: %r[^\h{2}/\h{2}/\h{64}/packages/\d+/files/\d+$],
debian_package_file: %r[^\h{2}/\h{2}/\h{64}/packages/debian/files/\d+$]
}.each do |factory, store_dir_regex|
context factory.to_s do
let(:package_file) { create(factory) } # rubocop:disable Rails/SaveBang
let(:uploader) { described_class.new(package_file, :file) } let(:uploader) { described_class.new(package_file, :file) }
let(:path) { Gitlab.config.packages.storage_path } let(:path) { Gitlab.config.packages.storage_path }
subject { uploader } subject { uploader }
it_behaves_like "builds correct paths", it_behaves_like "builds correct paths",
store_dir: %r[\h{2}/\h{2}], store_dir: store_dir_regex,
cache_dir: %r[/packages/tmp/cache], cache_dir: %r[/packages/tmp/cache],
work_dir: %r[/packages/tmp/work] work_dir: %r[/packages/tmp/work]
...@@ -21,11 +26,11 @@ RSpec.describe Packages::PackageFileUploader do ...@@ -21,11 +26,11 @@ RSpec.describe Packages::PackageFileUploader do
include_context 'with storage', described_class::Store::REMOTE include_context 'with storage', described_class::Store::REMOTE
it_behaves_like "builds correct paths", it_behaves_like "builds correct paths",
store_dir: %r[\h{2}/\h{2}] store_dir: store_dir_regex
end end
describe 'remote file' do describe 'remote file' do
let(:package_file) { create(:package_file, :object_storage, :xml) } let(:package_file) { create(factory, :object_storage) }
context 'with object storage enabled' do context 'with object storage enabled' do
before do before do
...@@ -42,4 +47,6 @@ RSpec.describe Packages::PackageFileUploader do ...@@ -42,4 +47,6 @@ RSpec.describe Packages::PackageFileUploader do
end end
end end
end end
end
end
end end
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