Skip to content

Commit

Permalink
[Backport to 3.3.x][Fixes #9166] Upload Workflow: The upload api keep…
Browse files Browse the repository at this point in the history
…s calling the "final" step causing inconsistent states (#9171)
  • Loading branch information
Alessio Fabiani authored Apr 19, 2022
1 parent 13ce257 commit 31efb6e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 0 additions & 2 deletions geonode/upload/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ def set_processing_state(self, state):
Upload.objects.filter(id=self.id).update(state=state)
if self.layer:
self.layer.set_processing_state(state)
if self.state != Upload.STATE_PROCESSED:
self.layer.set_dirty_state()

def __str__(self):
return f'Upload [{self.pk}] gs{self.import_id} - {self.name}, {self.user}'
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def finalize_incomplete_session_uploads(self, *args, **kwargs):

# Let's finish the valid ones
session = None
for _upload in Upload.objects.exclude(state__in=[Upload.STATE_RUNNING, Upload.STATE_PROCESSED, Upload.STATE_INVALID]).exclude(id__in=_upload_ids_expired):
for _upload in Upload.objects.exclude(state__in=[Upload.STATE_PROCESSED, Upload.STATE_INVALID]).exclude(id__in=_upload_ids_expired):
try:
if not _upload.import_id:
raise NotFound
Expand Down
7 changes: 2 additions & 5 deletions geonode/upload/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,16 +780,13 @@ def view(req, step=None):
upload_session = _get_upload_session(req)
if upload_session:
Upload.objects.update_from_session(upload_session)
if resp_js and isinstance(resp_js, dict):
if not settings.ASYNC_SIGNALS and resp_js and isinstance(resp_js, dict):
_success = resp_js.get('success', False)
_redirect_to = resp_js.get('redirect_to', '')
_required_input = resp_js.get('required_input', False)
if _success and (_required_input or 'upload/final' in _redirect_to):
from geonode.upload.tasks import finalize_incomplete_session_uploads
if settings.ASYNC_SIGNALS:
finalize_incomplete_session_uploads.apply_async()
else:
finalize_incomplete_session_uploads.apply()
finalize_incomplete_session_uploads.apply()
return resp
except BadStatusLine:
logger.exception('bad status line, geoserver down?')
Expand Down

0 comments on commit 31efb6e

Please sign in to comment.