Backport of "Use Geo log to remove files when migrated to object storage"

This commit is contained in:
Toon Claes 2018-10-03 15:09:16 +00:00 committed by Douglas Barbosa Alexandre
parent f4db21eb22
commit c5597547a1
5 changed files with 24 additions and 0 deletions

View File

@ -63,6 +63,12 @@ class GitlabUploader < CarrierWave::Uploader::Base
super || file&.filename
end
def relative_path
return path if pathname.relative?
pathname.relative_path_from(Pathname.new(root))
end
def model_valid?
!!model
end
@ -115,4 +121,8 @@ class GitlabUploader < CarrierWave::Uploader::Base
# the cache directory.
File.join(work_dir, cache_id, version_name.to_s, for_file)
end
def pathname
@pathname ||= Pathname.new(path)
end
end

View File

@ -9,6 +9,8 @@ class JobArtifactUploader < GitlabUploader
storage_options Gitlab.config.artifacts
alias_method :upload, :model
def cached_size
return model.size if model.size.present? && !model.file_changed?

View File

@ -8,6 +8,8 @@ class LegacyArtifactUploader < GitlabUploader
storage_options Gitlab.config.artifacts
alias_method :upload, :model
def store_dir
dynamic_segment
end

View File

@ -6,6 +6,8 @@ class LfsObjectUploader < GitlabUploader
storage_options Gitlab.config.lfs
alias_method :upload, :model
def filename
model.oid[4..-1]
end

View File

@ -33,6 +33,14 @@ shared_examples "builds correct paths" do |**patterns|
it_behaves_like "matches the method pattern", :upload_path
end
describe "#relative_path" do
it 'is relative' do
skip 'Path not set, skipping.' unless subject.path
expect(Pathname.new(subject.relative_path)).to be_relative
end
end
describe ".absolute_path" do
it_behaves_like "matches the method pattern", :absolute_path do
let(:target) { subject.class }