プロジェクト

全般

プロフィール

Vote #80983

完了

When creating more than two identical attachments in a single db transaction, the first one always ends up unreadable

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Attachments_19
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
19
version_id:
161
issue_org_id:
33769
author_id:
40856
assigned_to_id:
332
comments:
4
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

Due to the file re-using code running in an @after_commit@ hook, the hooks of any attachments that are created in a common db transaction will be deferred and run one after another after the outer transaction was committed. The existing implementation does not take that into account and as a consequence, when creating more than two identical attachments in a single transaction, the first attachment will end up with a non-existing @diskfile@.

The attached patch includes a test reproducing the issue and a fix, which consists of using @last@ instead of @first@ when finding an existing attachment to re-use. This way, the selected attachment is consistent across all runs of the hook even if multiple candidates exist. I also added an explicit @order@ call for good measure.

This is a corner case that should never occur in normal Redmine usage - but may occur in 3rd party code that's creating many attachments wrapped in a transaction.


journals

Setting the target version to 4.0.8.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed the fix. Thank you for your contribution.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

duplicates,Closed,28440,After commit missing file

Admin Redmine さんが約4年前に更新

  • カテゴリAttachments_19 にセット
  • 対象バージョン4.0.8_161 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0