Merge pull request #7099 from ivanscinote/SCI-10103-ik2

Fix asset sync update to account for WOPI and post process [SCI-10103]
This commit is contained in:
Martin Artnik 2024-02-16 10:46:00 +01:00 committed by GitHub
commit da8f2ff217
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,8 @@
# frozen_string_literal: true
class AssetSyncController < ApplicationController
include FileIconsHelper
skip_before_action :authenticate_user!, only: %i(update download)
skip_before_action :verify_authenticity_token, only: %i(update download)
before_action :authenticate_asset_sync_token!, only: %i(update download)
@ -36,9 +38,19 @@ class AssetSyncController < ApplicationController
return
end
orig_file_size = @asset.file_size
ActiveRecord::Base.transaction do
@asset.update(last_modified_by: current_user)
@asset.file.attach(io: request.body, filename: @asset.file.filename)
if wopi_file?(@asset)
@asset.update_contents(request.body)
else
@asset.file.attach(io: request.body, filename: @asset.file.filename)
@asset.touch
end
@asset.team.release_space(orig_file_size)
@asset.post_process_file
log_activity(:edit)
end