Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
fb657a511a
commit
a45caca386
|
@ -22,6 +22,8 @@ class Packages::PackageFileUploader < GitlabUploader
|
|||
def dynamic_segment
|
||||
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
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Use a dynamic segment not depending on the package id for Debian files
|
||||
merge_request: 50433
|
||||
author: Mathieu Parent
|
||||
type: changed
|
|
@ -2,43 +2,50 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Packages::PackageFileUploader do
|
||||
let(:package_file) { create(:package_file, :xml) }
|
||||
let(:uploader) { described_class.new(package_file, :file) }
|
||||
let(:path) { Gitlab.config.packages.storage_path }
|
||||
{
|
||||
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(:path) { Gitlab.config.packages.storage_path }
|
||||
|
||||
subject { uploader }
|
||||
subject { uploader }
|
||||
|
||||
it_behaves_like "builds correct paths",
|
||||
store_dir: %r[\h{2}/\h{2}],
|
||||
cache_dir: %r[/packages/tmp/cache],
|
||||
work_dir: %r[/packages/tmp/work]
|
||||
it_behaves_like "builds correct paths",
|
||||
store_dir: store_dir_regex,
|
||||
cache_dir: %r[/packages/tmp/cache],
|
||||
work_dir: %r[/packages/tmp/work]
|
||||
|
||||
context 'object store is remote' do
|
||||
before do
|
||||
stub_package_file_object_storage
|
||||
end
|
||||
context 'object store is remote' do
|
||||
before do
|
||||
stub_package_file_object_storage
|
||||
end
|
||||
|
||||
include_context 'with storage', described_class::Store::REMOTE
|
||||
include_context 'with storage', described_class::Store::REMOTE
|
||||
|
||||
it_behaves_like "builds correct paths",
|
||||
store_dir: %r[\h{2}/\h{2}]
|
||||
end
|
||||
|
||||
describe 'remote file' do
|
||||
let(:package_file) { create(:package_file, :object_storage, :xml) }
|
||||
|
||||
context 'with object storage enabled' do
|
||||
before do
|
||||
stub_package_file_object_storage
|
||||
it_behaves_like "builds correct paths",
|
||||
store_dir: store_dir_regex
|
||||
end
|
||||
|
||||
it 'can store file remotely' do
|
||||
allow(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async)
|
||||
describe 'remote file' do
|
||||
let(:package_file) { create(factory, :object_storage) }
|
||||
|
||||
package_file
|
||||
context 'with object storage enabled' do
|
||||
before do
|
||||
stub_package_file_object_storage
|
||||
end
|
||||
|
||||
expect(package_file.file_store).to eq(described_class::Store::REMOTE)
|
||||
expect(package_file.file.path).not_to be_blank
|
||||
it 'can store file remotely' do
|
||||
allow(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async)
|
||||
|
||||
package_file
|
||||
|
||||
expect(package_file.file_store).to eq(described_class::Store::REMOTE)
|
||||
expect(package_file.file.path).not_to be_blank
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue