Răsfoiți Sursa

Use conditional set/remove to cope with race conditions.

Jelmer Vernooij 8 ani în urmă
părinte
comite
42884f54f3
1 a modificat fișierele cu 2 adăugiri și 2 ștergeri
  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: