neos / neos-development-collection

The unified repository containing the Neos core packages, used for Neos development.
https://www.neos.io/
GNU General Public License v3.0
260 stars 220 forks source link

BUG: Prevent multiple/parallel imports of external asset source assets #5116

Closed so-grimm closed 4 weeks ago

so-grimm commented 1 month ago

Is there an existing issue for this?

Current Behavior

When using an external asset source, assets get imported when they are selected for use via the media selection screen (if they have not previously been imported). To check if an asset needs to be imported, the system checks if the asset already has a localAssetIdentifier. If it doesn't have the localAssetIdentifier, the importAction() of the Neos\Media\Browser\Controller\AssetProxyController is triggered.

The import process takes a few moments. Once it finishes, the asset is selected an the media selection screen closes. The user does not get any feedback about any background processes running and is not blocked from clicking on the asset again. Since editors tend to be impatient, this leads to them clicking on the asset multiple times, triggering the import multiple times and leading to several versions of the same asset being imported into the database.

Expected Behavior

An asset import process should only be triggered once. After it started running, it should not allow another import process to be started for the same asset.

We already discussed a few ideas for how to implement that. The best way seems to be to have a process queue/stack. We were also thinking that it might be a good idea to have a cleanup command for projects that already have that problem, so the database doesn't have redundant assets.

Steps To Reproduce

  1. implement a remote asset source
  2. find an asset that has not yet been imported (you can check that with the browser tools -> data-local-asset-identifier should not have a value)
  3. select that asset for use via the media selection screen and click on it multiple times before the selection screen closes
  4. check the neos_media_domain_model_importedasset table in your database, counting the entries for each remoteassetidentifier (SELECT remoteassetidentifier, count(*) FROM neos_media_domain_model_importedasset GROUP BY remoteassetidentifier ORDER BY count(*) DESC;)

Environment

- Flow: 8.3
- Neos: 8.3
- PHP: 8.2

Anything else?

No response

ahaeslich commented 4 weeks ago

Thx for taking care