Skip to content

Commit

Permalink
[Fixes #12828] New remote datasets are not registered inside proxy al…
Browse files Browse the repository at this point in the history
…lowed hosts when GeoNode runs asynchoronously
  • Loading branch information
mattiagiupponi committed Jan 21, 2025
1 parent 8c929f5 commit f255031
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion geonode/proxy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.conf import settings
from django.db.models import signals

from django.utils.timezone import now

site_url = urlsplit(settings.SITEURL)

Expand All @@ -11,6 +11,7 @@

class ProxyUrlsRegistry:
_first_init = True
_last_registry_load = None

def initialize(self):
from geonode.base.models import Link
Expand All @@ -30,6 +31,8 @@ def initialize(self):
signals.post_delete.connect(link_post_delete, sender=Link)
self._first_init = False

self._last_registry_load = now()

def set(self, hosts):
self.proxy_allowed_hosts = set(hosts)
return self
Expand All @@ -45,6 +48,10 @@ def unregister_host(self, host):
self.proxy_allowed_hosts.remove(host)

def get_proxy_allowed_hosts(self):
if self._last_registry_load is None or (now() - self._last_registry_load).days >= getattr(
settings, "PROXY_RELOAD_REGISTRY_THRESHOLD_DAYS", 1
):
self.initialize()
return self.proxy_allowed_hosts


Expand Down

0 comments on commit f255031

Please sign in to comment.