mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Maintain backwards compatibility before Jobs::MigrateUploadExtensions
runs.
This commit is contained in:
parent
a47e297508
commit
8cc8010564
@ -95,7 +95,16 @@ module FileStore
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_path_for_upload(upload)
|
def get_path_for_upload(upload)
|
||||||
get_path_for("original".freeze, upload.id, upload.sha1, "." + upload.extension)
|
extension =
|
||||||
|
if upload.extension
|
||||||
|
".#{upload.extension}"
|
||||||
|
else
|
||||||
|
# Maintain backward compatibility before Jobs::MigrateUploadExtensions
|
||||||
|
# runs
|
||||||
|
File.extname(upload.original_filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
get_path_for("original".freeze, upload.id, upload.sha1, extension)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_path_for_optimized_image(optimized_image)
|
def get_path_for_optimized_image(optimized_image)
|
||||||
|
21
spec/components/file_store/base_store_spec.rb
Normal file
21
spec/components/file_store/base_store_spec.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe FileStore::BaseStore do
|
||||||
|
let(:upload) { Fabricate(:upload, id: 9999, sha1: Digest::SHA1.hexdigest('9999')) }
|
||||||
|
|
||||||
|
describe '#get_path_for_upload' do
|
||||||
|
it 'should return the right path' do
|
||||||
|
expect(FileStore::BaseStore.new.get_path_for_upload(upload))
|
||||||
|
.to eq('original/2X/4/4170ac2a2782a1516fe9e13d7322ae482c1bd594.png')
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when Upload#extension has not been set' do
|
||||||
|
it 'should return the right path' do
|
||||||
|
upload.update!(extension: nil)
|
||||||
|
|
||||||
|
expect(FileStore::BaseStore.new.get_path_for_upload(upload))
|
||||||
|
.to eq('original/2X/4/4170ac2a2782a1516fe9e13d7322ae482c1bd594.png')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user