Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layer post_save deletes links to external thumbnails / data #4739

Closed
srtonz opened this issue Aug 15, 2019 · 1 comment
Closed

Layer post_save deletes links to external thumbnails / data #4739

srtonz opened this issue Aug 15, 2019 · 1 comment
Labels
minor A low priority issue which might affect only some users and /or not the main functionality needs further investigation Issue or reason for specific behaviour needs further investigation
Milestone

Comments

@srtonz
Copy link

srtonz commented Aug 15, 2019

Expected Behavior

When saving a layer, existing links should only be updated / deleted if required.

Actual Behavior

When saving a layer, links to external data such as thumbnails stored on a static file host are deleted.

Steps to Reproduce the Problem

  1. Set a layer's thumbnail link to an external image through the admin panel
  2. Save the layer through the admin panel
  3. Thumbnail is deleted

Specifications

  • GeoNode version: 2.10
  • Installation method (manual, GeoNode Docker, SPCGeoNode Docker): manual docker
  • Platform: ubuntu
  • Additional details:

Reasons

After saving a layer, the resourcebase_post_save signal is triggered. It deletes any links that do not point to the same host as our GeoNode instance:

geonode/geonode/base/models.py

Lines 1412 to 1424 in c999687

def resourcebase_post_save(instance, *args, **kwargs):
"""
Used to fill any additional fields after the save.
Has to be called by the children
"""
# we need to remove stale links
for link in instance.link_set.all():
if link.name == "External Document":
if link.resource.doc_url != link.url:
link.delete()
else:
if urlsplit(settings.SITEURL).hostname not in link.url:
link.delete()

I'm not entirely sure why this behaviour exists, so I'm hesitant to submit a pull request. I think having external resources is a very valid scenario, but there may be a reason for deleting links to external hosts?

@srtonz srtonz changed the title resourcebase_post_save stale link behaviour Layer post_save deletes links to external thumbnails / data Aug 15, 2019
@afabiani afabiani added minor A low priority issue which might affect only some users and /or not the main functionality needs further investigation Issue or reason for specific behaviour needs further investigation labels Aug 21, 2019
@afabiani
Copy link
Member

@geotob we need to try to understand which was the original intent of this code. At first glance, I agree with you. It doesn't seem to make much sense to delete the old links.
Maybe this was introduced to keep the server IP/name consistent?

@afabiani afabiani added this to the 2.10.1 milestone Sep 27, 2019
afabiani pushed a commit that referenced this issue Sep 27, 2019
[Fixes #4739] Layer post_save deletes links to external thumbnails / …
afabiani pushed a commit that referenced this issue Sep 28, 2019
[Backport 2.10.x] [Fixes #4739] Layer post_save deletes links to external thumbnails / …
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor A low priority issue which might affect only some users and /or not the main functionality needs further investigation Issue or reason for specific behaviour needs further investigation
Projects
None yet
Development

No branches or pull requests

2 participants