Skip to content

Commit

Permalink
- Fix: race on upload transaction
Browse files Browse the repository at this point in the history
(cherry picked from commit 73c2677)
  • Loading branch information
afabiani committed Nov 29, 2021
1 parent bf444e5 commit adfb821
Showing 1 changed file with 26 additions and 33 deletions.
59 changes: 26 additions & 33 deletions geonode/upload/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,40 +696,33 @@ def final_step(upload_session, user, charset="UTF-8", layer_id=None):
saved_layer = None
if upload_session.mosaic:
if not upload_session.append_to_mosaic_opts:
try:
with transaction.atomic():
saved_dataset_filter = Layer.objects.filter(
store=target.name,
alternate=alternate,
workspace=target.workspace_name,
name=task.layer.name)
if not saved_dataset_filter.exists():
saved_layer = Layer.objects.create(
uuid=layer_uuid or str(uuid.uuid1()),
store=target.name,
storeType=target.store_type,
alternate=alternate,
workspace=target.workspace_name,
title=title,
name=task.layer.name,
abstract=abstract or '',
owner=user,
temporal_extent_start=start,
temporal_extent_end=end,
is_mosaic=True,
has_time=has_time,
has_elevation=has_elevation,
time_regex=upload_session.mosaic_time_regex)
created = True
else:
saved_layer = saved_dataset_filter.get()
created = False
except IntegrityError as e:
Upload.objects.invalidate_from_session(upload_session)
raise UploadException.from_exc(_('Error configuring Layer'), e)
saved_dataset_filter = Layer.objects.filter(
store=target.name,
alternate=alternate,
workspace=target.workspace_name,
name=task.layer.name)
if not saved_dataset_filter.exists():
saved_layer = Layer.objects.create(
uuid=layer_uuid or str(uuid.uuid1()),
store=target.name,
storeType=target.store_type,
alternate=alternate,
workspace=target.workspace_name,
title=title,
name=task.layer.name,
abstract=abstract or '',
owner=user,
temporal_extent_start=start,
temporal_extent_end=end,
is_mosaic=True,
has_time=has_time,
has_elevation=has_elevation,
time_regex=upload_session.mosaic_time_regex)
created = True
else:
saved_layer = saved_dataset_filter.get()
created = False
else:
# saved_layer = Layer.objects.filter(name=upload_session.append_to_mosaic_name)
# created = False
saved_layer, created = Layer.objects.get_or_create(
name=upload_session.append_to_mosaic_name)
try:
Expand Down

0 comments on commit adfb821

Please sign in to comment.