mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 03:59:51 +08:00
Merge pull request #7103 from artoscinote/ma_SCI_10228
Fix making backup copy of conflicting files [SCI-10228]
This commit is contained in:
commit
41df10a2ee
1 changed files with 8 additions and 2 deletions
|
@ -87,11 +87,15 @@ class AssetSyncController < ApplicationController
|
|||
Asset.transaction do
|
||||
new_asset = @asset.dup
|
||||
new_asset.save
|
||||
new_asset.file.attach(
|
||||
|
||||
blob = ActiveStorage::Blob.create_and_upload!(
|
||||
io: request.body,
|
||||
filename: "#{@asset.file.filename.base} (#{t('general.copy')}).#{@asset.file.filename.extension}"
|
||||
filename: "#{@asset.file.filename.base} (#{t('general.copy')}).#{@asset.file.filename.extension}",
|
||||
metadata: @asset.blob.metadata
|
||||
)
|
||||
|
||||
new_asset.file.attach(blob)
|
||||
|
||||
case @asset.parent
|
||||
when Step
|
||||
StepAsset.create!(step: @asset.step, asset: new_asset)
|
||||
|
@ -101,6 +105,8 @@ class AssetSyncController < ApplicationController
|
|||
|
||||
@asset = new_asset.reload
|
||||
|
||||
new_asset.post_process_file
|
||||
|
||||
current_user.asset_sync_tokens.create!(asset_id: new_asset.id)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue