Commit 88c1cf67 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'tc-geo-log-object-storage-ce' into 'master'

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

See merge request gitlab-org/gitlab-ce!22049
parents f4db21eb c5597547
...@@ -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