aboutsummaryrefslogtreecommitdiff
path: root/refstore/files/update_lock_packed.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-25 14:31:16 +0000
committerGravatar Runxi Yu2026-03-25 14:31:16 +0000
commit48ff647cf4a8bb8f23fcd6b8616f56a8ef72b980 (patch)
treeae199c38042adaa544d5f7d31351661d5831381e /refstore/files/update_lock_packed.go
parent*: objectstore -> object/store (diff)
signatureNo signature
*: refstore -> ref/store
Diffstat (limited to 'refstore/files/update_lock_packed.go')
-rw-r--r--refstore/files/update_lock_packed.go44
1 files changed, 0 insertions, 44 deletions
diff --git a/refstore/files/update_lock_packed.go b/refstore/files/update_lock_packed.go
deleted file mode 100644
index f74a4f5e..00000000
--- a/refstore/files/update_lock_packed.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package files
-
-import (
- "errors"
- "os"
- "time"
-)
-
-func (executor *refUpdateExecutor) createPackedRefsLock(timeout time.Duration) error {
- const (
- initialBackoffMs = 1
- backoffMaxMultiplier = 1000
- )
-
- deadline := time.Now().Add(timeout)
- multiplier := 1
- n := 1
-
- for {
- file, err := executor.store.commonRoot.OpenFile("packed-refs.lock", os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644)
- if err == nil {
- return file.Close()
- }
-
- if !errors.Is(err, os.ErrExist) {
- return err
- }
-
- if timeout == 0 || (timeout > 0 && time.Now().After(deadline)) {
- return err
- }
-
- backoffMs := multiplier * initialBackoffMs
- waitMs := (750 + executor.store.lockRand.Intn(500)) * backoffMs / 1000
- time.Sleep(time.Duration(waitMs) * time.Millisecond)
-
- multiplier += 2*n + 1
- if multiplier > backoffMaxMultiplier {
- multiplier = backoffMaxMultiplier
- } else {
- n++
- }
- }
-}