core-geonetwork
core-geonetwork copied to clipboard
Upload a logo with duplicated name removes the logo
Describe the bug Uploading a logo with an exisiting name, returns an error message about resource duplicated, that is fine, but the logo is removed from the catalogue.
Tested in 3.12.x and 3.10.x, probably affects also 4.0.x.
To Reproduce Steps to reproduce the behavior:
- Login as administrator and go to Administration > Settings > Logo
- Upload a logo file --> The logo file is displayed in the logo list
- Upload again the same file --> An error message about logo duplicated is displayed (correct), but the logo list is refreshed and the logo is not displayed anymore. Refreshing the page has the same effect.
Expected behavior When uploading a duplicated logo file, an error message is displayed, the original logo is preserved.
Maybe would be even better, just to update the file?
The problem is related to this code:
https://github.com/geonetwork/core-geonetwork/blob/57a963d64262eb9625f04bae0247ab6cec799078/services/src/main/java/org/fao/geonet/api/site/LogosApi.java#L163-L164
https://github.com/geonetwork/core-geonetwork/blob/57a963d64262eb9625f04bae0247ab6cec799078/core/src/main/java/org/fao/geonet/resources/FileResources.java#L213-L216
The logic in the LogosApi
, was added in S3 implementation: https://github.com/geonetwork/core-geonetwork/commit/80d51399076a2f1fb7b5049949312d451db8db63
In S3 store, the code makes more sense:
https://github.com/geonetwork/core-geonetwork/blob/57a963d64262eb9625f04bae0247ab6cec799078/core/src/main/java/org/fao/geonet/resources/S3Resources.java#L317-L320
according to the documentation of the method in the ResourceHolder
interface:
https://github.com/geonetwork/core-geonetwork/blob/57a963d64262eb9625f04bae0247ab6cec799078/core/src/main/java/org/fao/geonet/resources/Resources.java#L368-L371
@fxprunayre any idea why the FileResources.abort()
method is removing the file?