GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit fbfb9f1e authored by Daniel Gerhardt's avatar Daniel Gerhardt Committed by Tom Käsler

Revert "use fileuploader dynamic path method in uploads manager and add spec"

This reverts commit 07ec2c7b.
parent 55c863d8
...@@ -67,10 +67,6 @@ def self.generate_secret ...@@ -67,10 +67,6 @@ def self.generate_secret
SecureRandom.hex SecureRandom.hex
end end
def self.extract_dynamic_path(path)
DYNAMIC_PATH_PATTERN.match(path)
end
def upload_paths(identifier) def upload_paths(identifier)
[ [
File.join(secret, identifier), File.join(secret, identifier),
...@@ -145,7 +141,7 @@ def upload=(value) ...@@ -145,7 +141,7 @@ def upload=(value)
return if apply_context!(value.uploader_context) return if apply_context!(value.uploader_context)
# fallback to the regex based extraction # fallback to the regex based extraction
if matches = self.class.extract_dynamic_path(value.path) if matches = DYNAMIC_PATH_PATTERN.match(value.path)
@secret = matches[:secret] @secret = matches[:secret]
@identifier = matches[:identifier] @identifier = matches[:identifier]
end end
......
...@@ -38,7 +38,12 @@ def restore ...@@ -38,7 +38,12 @@ def restore
private private
def add_upload(upload) def add_upload(upload)
uploader_context = FileUploader.extract_dynamic_path(upload).named_captures.symbolize_keys secret, identifier = upload.split('/').last(2)
uploader_context = {
secret: secret,
identifier: identifier
}
UploadService.new(@project, File.open(upload, 'r'), FileUploader, uploader_context).execute.to_h UploadService.new(@project, File.open(upload, 'r'), FileUploader, uploader_context).execute.to_h
end end
......
...@@ -141,15 +141,6 @@ def store_dir ...@@ -141,15 +141,6 @@ def store_dir
end end
end end
describe '.extract_dynamic_path' do
it 'works with hashed storage' do
path = 'export/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a/test/uploads/72a497a02fe3ee09edae2ed06d390038/dummy.txt'
expect(described_class.extract_dynamic_path(path)[:identifier]).to eq('dummy.txt')
expect(described_class.extract_dynamic_path(path)[:secret]).to eq('72a497a02fe3ee09edae2ed06d390038')
end
end
describe '#secret' do describe '#secret' do
it 'generates a secret if none is provided' do it 'generates a secret if none is provided' do
expect(described_class).to receive(:generate_secret).and_return('secret') expect(described_class).to receive(:generate_secret).and_return('secret')
......
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