aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2022-12-28 20:31:06 +0100
committerDaniel Schadt <kingdread@gmx.de>2022-12-28 20:31:06 +0100
commitd4c20086e745d3eb61de6fdbeba88792e10b83f5 (patch)
tree88a09c44d0ef2a84a182dc5c2c9d1163ea911f17
parent14bb11ac50abf7eafd02c7570ccf1221b779a62d (diff)
downloadfietsboek-d4c20086e745d3eb61de6fdbeba88792e10b83f5.tar.gz
fietsboek-d4c20086e745d3eb61de6fdbeba88792e10b83f5.tar.bz2
fietsboek-d4c20086e745d3eb61de6fdbeba88792e10b83f5.zip
lock track directory when editing
This is important if concurrent requests to edit the same track are made, both for images and later for metadata embedding.
-rw-r--r--fietsboek/views/edit.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/fietsboek/views/edit.py b/fietsboek/views/edit.py
index a26452d..b3dcf1e 100644
--- a/fietsboek/views/edit.py
+++ b/fietsboek/views/edit.py
@@ -81,20 +81,22 @@ def do_edit(request):
if any(user not in track.tagged_people and user not in user_friends for user in tagged_people):
return HTTPBadRequest()
+ data = request.data_manager.open(track.id)
tz_offset = datetime.timedelta(minutes=int(request.params["date-tz"]))
date = datetime.datetime.fromisoformat(request.params["date"])
- track.date = date.replace(tzinfo=datetime.timezone(tz_offset))
-
- track.tagged_people = tagged_people
- track.title = request.params["title"]
- track.visibility = Visibility[request.params["visibility"]]
- track.type = TrackType[request.params["type"]]
- track.description = request.params["description"]
- track.badges = badges
- tags = request.params.getall("tag[]")
- track.sync_tags(tags)
-
- edit_images(request, request.context)
+ with data.lock():
+ track.date = date.replace(tzinfo=datetime.timezone(tz_offset))
+
+ track.tagged_people = tagged_people
+ track.title = request.params["title"]
+ track.visibility = Visibility[request.params["visibility"]]
+ track.type = TrackType[request.params["type"]]
+ track.description = request.params["description"]
+ track.badges = badges
+ tags = request.params.getall("tag[]")
+ track.sync_tags(tags)
+
+ edit_images(request, request.context)
return HTTPFound(request.route_url("details", track_id=track.id))