FEATURE: Use path from existing URL of uploads and optimized images (#13177)

Discourse shouldn't dynamically calculate the path of uploads and optimized images after a file has been stored on disk or S3. Otherwise it might calculate the wrong path if the SHA1 or extension stored in the database doesn't match the actual file path.
This commit is contained in:
Gerhard Schlager
2021-05-27 17:42:25 +02:00
committed by GitHub
parent bcbb5b4dae
commit 157f10db4c
11 changed files with 189 additions and 56 deletions

View File

@ -489,8 +489,8 @@ describe Email::Sender do
let!(:optimized_image_file) { file_from_fixtures("smallest.png", "images") }
before do
Discourse.store.store_optimized_image(optimized_image_file, optimized)
optimized.update(url: Discourse.store.absolute_base_url + '/' + optimized.url)
url = Discourse.store.store_optimized_image(optimized_image_file, optimized)
optimized.update(url: Discourse.store.absolute_base_url + '/' + url)
Discourse.store.cache_file(optimized_image_file, File.basename("#{optimized.sha1}.png"))
end