Browse Source

Use conditional set/remove to cope with race conditions.

Jelmer Vernooij 8 năm trước cách đây
mục cha
commit
42884f54f3
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      dulwich/server.py

+ 2 - 2
dulwich/server.py

@@ -891,12 +891,12 @@ class ReceivePackHandler(PackHandler):
                           'Attempted to delete refs without delete-refs '
                           'capability.')
                     try:
-                        del self.repo.refs[ref]
+                        self.repo.refs.remove_if_equals(ref, oldsha)
                     except all_exceptions:
                         ref_status = b'failed to delete'
                 else:
                     try:
-                        self.repo.refs[ref] = sha
+                        self.repo.refs.set_if_equals(ref, oldsha, sha)
                     except all_exceptions:
                         ref_status = b'failed to write'
             except KeyError as e: