Commit c5597547 authored by Toon Claes's avatar Toon Claes Committed by Douglas Barbosa Alexandre

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

parent f4db21eb
...@@ -63,6 +63,12 @@ class GitlabUploader < CarrierWave::Uploader::Base ...@@ -63,6 +63,12 @@ class GitlabUploader < CarrierWave::Uploader::Base
super || file&.filename super || file&.filename
end end
def relative_path
return path if pathname.relative?
pathname.relative_path_from(Pathname.new(root))
end
def model_valid? def model_valid?
!!model !!model
end end
...@@ -115,4 +121,8 @@ class GitlabUploader < CarrierWave::Uploader::Base ...@@ -115,4 +121,8 @@ class GitlabUploader < CarrierWave::Uploader::Base
# the cache directory. # the cache directory.
File.join(work_dir, cache_id, version_name.to_s, for_file) File.join(work_dir, cache_id, version_name.to_s, for_file)
end end
def pathname
@pathname ||= Pathname.new(path)
end
end end
...@@ -9,6 +9,8 @@ class JobArtifactUploader < GitlabUploader ...@@ -9,6 +9,8 @@ class JobArtifactUploader < GitlabUploader
storage_options Gitlab.config.artifacts storage_options Gitlab.config.artifacts
alias_method :upload, :model
def cached_size def cached_size
return model.size if model.size.present? && !model.file_changed? return model.size if model.size.present? && !model.file_changed?
......
...@@ -8,6 +8,8 @@ class LegacyArtifactUploader < GitlabUploader ...@@ -8,6 +8,8 @@ class LegacyArtifactUploader < GitlabUploader
storage_options Gitlab.config.artifacts storage_options Gitlab.config.artifacts
alias_method :upload, :model
def store_dir def store_dir
dynamic_segment dynamic_segment
end end
......
...@@ -6,6 +6,8 @@ class LfsObjectUploader < GitlabUploader ...@@ -6,6 +6,8 @@ class LfsObjectUploader < GitlabUploader
storage_options Gitlab.config.lfs storage_options Gitlab.config.lfs
alias_method :upload, :model
def filename def filename
model.oid[4..-1] model.oid[4..-1]
end end
......
...@@ -33,6 +33,14 @@ shared_examples "builds correct paths" do |**patterns| ...@@ -33,6 +33,14 @@ shared_examples "builds correct paths" do |**patterns|
it_behaves_like "matches the method pattern", :upload_path it_behaves_like "matches the method pattern", :upload_path
end 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 describe ".absolute_path" do
it_behaves_like "matches the method pattern", :absolute_path do it_behaves_like "matches the method pattern", :absolute_path do
let(:target) { subject.class } let(:target) { subject.class }
......
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