Project

General

Profile

Actions

Defect #44620

open

Partially written thumbnails may be served

Added by Go MAEDA about 8 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Attachments
Resolution:
Affected version:

Description

Redmine::Thumbnail.generate writes the thumbnail directly to its final path and skips generation whenever a file already exists there. As a result, an incomplete thumbnail can be served in two cases.

First, a request that arrives while ImageMagick is still writing the thumbnail for another request receives an empty or truncated file. This can happen when several users open an issue with image attachments at the same time, and is more likely with PDF thumbnails, which take longer to generate. Since the ETag is based on the thumbnail path, browsers keep showing the broken image even after the thumbnail is complete.

Second, if ImageMagick fails or exceeds thumbnails_generation_timeout, the partially written file is left in place and served from then on. It can only be fixed by deleting the file manually.

The attached patch writes the thumbnail to a temporary file in the same directory, so that it can be atomically renamed to the target path once ImageMagick succeeds. Other requests therefore see either no file or the complete thumbnail. The temporary file is removed if ImageMagick fails or times out.


Files

No data to display

Actions

Also available in: Atom PDF