mirror of
https://github.com/suitenumerique/drive.git
synced 2026-09-30 21:45:15 +02:00
🔥(backend) remove usage of atomic transaction for item creation
We used atomic transaction in the ItemViewset when a new item is created (perform_create and children actions). This code can be removed seen we decided to use UUID for the item path. The race condition possible when multiple items are created does not exists anymore, we don't need to know previously created item to guess the next path.
This commit is contained in:
@@ -12,6 +12,10 @@ and this project adheres to
|
||||
|
||||
- 🏗️ (ds_proxy) introduce how to use ds_proxy with Drive
|
||||
|
||||
### Changed
|
||||
|
||||
- 🔥(backend) remove usage of atomic transaction for item creation
|
||||
|
||||
## [v0.11.1] - 2026-01-13
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -572,7 +572,6 @@ class ItemViewSet(
|
||||
|
||||
return drf.response.Response(serializer.data)
|
||||
|
||||
@transaction.atomic
|
||||
def perform_create(self, serializer):
|
||||
"""Set the current user as creator and owner of the newly created object."""
|
||||
obj = models.Item.objects.create_child(
|
||||
@@ -911,12 +910,11 @@ class ItemViewSet(
|
||||
)
|
||||
)
|
||||
|
||||
with transaction.atomic():
|
||||
child_item = models.Item.objects.create_child(
|
||||
creator=request.user,
|
||||
parent=item,
|
||||
**serializer.validated_data,
|
||||
)
|
||||
child_item = models.Item.objects.create_child(
|
||||
creator=request.user,
|
||||
parent=item,
|
||||
**serializer.validated_data,
|
||||
)
|
||||
|
||||
# Set the created instance to the serializer
|
||||
serializer.instance = child_item
|
||||
|
||||
Reference in New Issue
Block a user