advanced-nova-media-library icon indicating copy to clipboard operation
advanced-nova-media-library copied to clipboard

Images are duplicated when the Resource is updated

Open edemots opened this issue 3 years ago • 6 comments

https://user-images.githubusercontent.com/28089352/123995072-3cb64280-d9ce-11eb-894e-c113df2e2b12.mov

edemots avatar Jun 30 '21 16:06 edemots

Btw, it also duplicates every Images/Files/Media registered

edemots avatar Jun 30 '21 16:06 edemots

@edemots were you able to solve this?

Peterragheb avatar Sep 15 '21 11:09 Peterragheb

I have the same problem. Has anyone found a solution?

pelmered avatar Sep 22 '21 15:09 pelmered

There is already a pull request https://github.com/ebess/advanced-nova-media-library/pull/212

prey87 avatar Feb 08 '22 10:02 prey87

This one definitely needs to be fixed. ~~The Media model calls the HandlesExistingMediaTrait::addExistingMedia() method while processing the request even when the enable-existing-media option is disabled in the config. All current media will be duplicated as they are posted with the update request.~~

image

Actually, while writing, I discovered the problem. The primary key of the Media model is an integer by default. When this is changed to a uuid, the in_array() check fails as the posted data is converted to an integer.

https://github.com/ebess/advanced-nova-media-library/blob/60c2932b7dde88359687dbc76f81c9d2e465adc0/src/Fields/HandlesExistingMediaTrait.php#L30

rubenflush avatar Feb 11 '22 10:02 rubenflush

Ah, great! @rubenflush! We use UUIDs so that is probably the reason. Thanks for the fix.

pelmered avatar Apr 14 '22 08:04 pelmered