geonetwork / geonetwork/core-geonetwork

Upload a logo with duplicated name removes the logo

Open
#5,841 1 comment 0 reactions 0 assignees View on GitHub
bug stale
Dominant language
Java
Stars
521
Forks
514
Avg merge
6d 13h
Merged PRs (30d)
19

Description

**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:
1. Login as administrator and go to Administration > Settings > Logo
2. Upload a logo file --> The logo file is displayed in the logo list
3. 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?

Contributor guide

Open the contributing guide

Research direction

Start by reading the referenced sections of services/src/main/java/org/fao/geonet/api/site/LogosApi.java and core/src/main/java/org/fao/geonet/resources/FileResources.java, then compare them with S3Resources.java and the ResourceHolder documentation in Resources.java. Reproduce the duplicate upload through Administration > Settings > Logo; done means the duplicate error appears while the original logo remains in the catalogue.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.