|
|
@ -23,6 +23,7 @@ import (
|
|
|
|
"io/ioutil"
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/gofrs/flock"
|
|
|
|
"github.com/gofrs/flock"
|
|
|
@ -85,8 +86,8 @@ func (o *repoAddOptions) run(out io.Writer) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Lock the repository file for concurrent goroutines or processes synchronization
|
|
|
|
// Acquire a file lock for process synchronization
|
|
|
|
fileLock := flock.New(o.repoFile)
|
|
|
|
fileLock := flock.New(strings.Replace(o.repoFile, filepath.Ext(o.repoFile), ".lock", 1))
|
|
|
|
lockCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
|
|
lockCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
defer cancel()
|
|
|
|
locked, err := fileLock.TryLockContext(lockCtx, time.Second)
|
|
|
|
locked, err := fileLock.TryLockContext(lockCtx, time.Second)
|
|
|
|