プロジェクト

全般

プロフィール

Vote #76578

完了

Removing attachment after commit transaction

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

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

0%

予定工数:
category_id:
19
version_id:
102
issue_org_id:
20388
author_id:
128697
assigned_to_id:
1
comments:
3
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

Now in Attachment model is

after_destroy :delete_from_disk

If you want to construct a serious logic with Rollback this behaviour leads to remove file from disk, but leave an attachment record in DB.
In my project I replaced this callback on

after_commit :delete_from_disk, on: :destroy

and it works perfect.

I think this is a good modification for Redmine. It have full backward compatibility but can extend ability for strong logic in app.


journals

--------------------------------------------------------------------------------
Notice: in Rails 4 appear new config option related with transaction callbacks:
<pre>
config.active_record.raise_in_transactional_callbacks = true
</pre> It allows to propagate errors from transaction callbacks. Preferable to turn it on.
--------------------------------------------------------------------------------
Change committed in r14630, thanks.
--------------------------------------------------------------------------------

Admin Redmine さんが3年以上前に更新

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

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

いいね!0
いいね!0