Media of draft items is deleted automatically
When creating a draft of an item, e. g. a tool, and applying a media, e. g. an image, and then waiting a day without publishing it, the media will be deleted by the MediaStorageGarbageCollector
. Afterwards it is not possible anymore to access the draft, as it raises the error javax.persistence.EntityNotFoundException: Media with id ----here the id---- not found
.
It is expected, that the MediaStorageGarbageCollector
respects that a media is attached to an draft and does not delete the media.
@ekalata could you change the behaviour of the MediaStorageGarbageCollector
so that it does not ignore drafts?
I can reproduce this error. I used my personal login with the role moderator on stage, create a draft with an image and then wait until the next day. It is after 24h (I'm not super sure if it is really 24h or some hours more or less) deleted and I can't access aynmore the draft item. Here the logs:
I see that the media is deleted:
29-03-2022 14:53:20.978 [scheduling-1] DEBUG e.s.m.d.m.MediaStorageGarbageCollector.lambda$deleteStaleMedia$2 - e7e5eb5f-4fe3-4423-bdd2-46354363da1d
and if I afterwards try to access the draft item, I get:
31-03-2022 15:05:09.110 [http-nio-8080-exec-8] ERROR e.s.m.c.MarketplaceExceptionHandler.handleEntityNotFoundException - No entity
javax.persistence.EntityNotFoundException: Media with id e7e5eb5f-4fe3-4423-bdd2-46354363da1d not found
at eu.sshopencloud.marketplace.domain.media.MediaStorageService.lambda$loadMediaData$3(MediaStorageService.java:272)
at java.base/java.util.Optional.orElseThrow(Unknown Source)
at eu.sshopencloud.marketplace.domain.media.MediaStorageService.loadMediaData(MediaStorageService.java:272)
at eu.sshopencloud.marketplace.domain.media.MediaStorageService.getMediaDetails(MediaStorageService.java:95)
at eu.sshopencloud.marketplace.domain.media.MediaStorageService$$FastClassBySpringCGLIB$$7d6fbd5a.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
...
@ekalata There are already some contributors that reported back, that they got this error. Do you see any chance that I can save the draft item by deleting the reference to the image in the dabase? I would delete the entry in the items_media
-table with the media-id that raises the not found error: do you think this is safe or will I need to delete something else?
Adding @lbarbot and @edward.gray so that they are up to date about the progress.
I guess we can also express that this is an error that involves already some contributors, therefore finding a solution should get a high priority.