Skip to content

Commit

Permalink
chore: merge kept data into existing data
Browse files Browse the repository at this point in the history
  • Loading branch information
smotornyuk committed Aug 29, 2024
1 parent 810ee4b commit 468162a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ckanext/files/logic/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,12 +695,6 @@ def files_multipart_complete(
storage=multipart.storage,
)

if data_dict["keep_storage_data"]:
fileobj.storage_data = copy.deepcopy(multipart.storage_data)

if data_dict["keep_plugin_data"]:
fileobj.plugin_data = copy.deepcopy(multipart.plugin_data)

try:
storage.multipart_complete(
shared.MultipartData.from_model(multipart),
Expand All @@ -709,6 +703,16 @@ def files_multipart_complete(
except shared.exc.UploadError as err:
raise tk.ValidationError({"upload": [str(err)]}) from err

if data_dict["keep_storage_data"]:
data: Any = copy.deepcopy(multipart.storage_data)
data.update(fileobj.storage_data)
fileobj.storage_data = data

if data_dict["keep_plugin_data"]:
data: Any = copy.deepcopy(multipart.plugin_data)
data.update(fileobj.plugin_data)
fileobj.plugin_data = data

sess.query(Owner).where(
Owner.item_type == "multipart",
Owner.item_id == multipart.id,
Expand Down

0 comments on commit 468162a

Please sign in to comment.