Spaces:
Running
Running
Update config_provider.py
Browse files- config_provider.py +5 -4
config_provider.py
CHANGED
@@ -268,9 +268,10 @@ class ConfigProvider:
|
|
268 |
if not project:
|
269 |
raise ResourceNotFoundError("project", project_id)
|
270 |
|
271 |
-
# Check race condition
|
272 |
-
if expected_last_update is not None:
|
273 |
-
|
|
|
274 |
raise RaceConditionError(
|
275 |
f"Project '{project.name}' was modified by another user",
|
276 |
current_user=username,
|
@@ -282,7 +283,7 @@ class ConfigProvider:
|
|
282 |
|
283 |
# Update fields
|
284 |
for key, value in update_data.items():
|
285 |
-
if hasattr(project, key) and key not in ['id', 'created_date', 'created_by', 'last_update_date']:
|
286 |
setattr(project, key, value)
|
287 |
|
288 |
project.last_update_date = datetime.utcnow().isoformat()
|
|
|
268 |
if not project:
|
269 |
raise ResourceNotFoundError("project", project_id)
|
270 |
|
271 |
+
# Check race condition - Eğer expected_last_update None ise kontrol etme
|
272 |
+
if expected_last_update is not None and expected_last_update != '':
|
273 |
+
# Eğer project'in last_update_date'i yoksa (ilk kez update ediliyor), race condition olmaz
|
274 |
+
if project.last_update_date and project.last_update_date != expected_last_update:
|
275 |
raise RaceConditionError(
|
276 |
f"Project '{project.name}' was modified by another user",
|
277 |
current_user=username,
|
|
|
283 |
|
284 |
# Update fields
|
285 |
for key, value in update_data.items():
|
286 |
+
if hasattr(project, key) and key not in ['id', 'created_date', 'created_by', 'last_update_date', 'last_update_user']:
|
287 |
setattr(project, key, value)
|
288 |
|
289 |
project.last_update_date = datetime.utcnow().isoformat()
|