repository: Lock requires *repository.Repository
This allows the Lock function to access the backend, even once the Backend method is removed from the interface.
This commit is contained in:
parent
d8b184b3d3
commit
67e2ba0d40
1 changed files with 3 additions and 3 deletions
|
@ -36,13 +36,13 @@ var lockerInst = &locker{
|
||||||
refreshabilityTimeout: restic.StaleLockTimeout - defaultRefreshInterval*3/2,
|
refreshabilityTimeout: restic.StaleLockTimeout - defaultRefreshInterval*3/2,
|
||||||
}
|
}
|
||||||
|
|
||||||
func Lock(ctx context.Context, repo restic.Repository, exclusive bool, retryLock time.Duration, printRetry func(msg string), logger func(format string, args ...interface{})) (*Unlocker, context.Context, error) {
|
func Lock(ctx context.Context, repo *Repository, exclusive bool, retryLock time.Duration, printRetry func(msg string), logger func(format string, args ...interface{})) (*Unlocker, context.Context, error) {
|
||||||
return lockerInst.Lock(ctx, repo, exclusive, retryLock, printRetry, logger)
|
return lockerInst.Lock(ctx, repo, exclusive, retryLock, printRetry, logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock wraps the ctx such that it is cancelled when the repository is unlocked
|
// Lock wraps the ctx such that it is cancelled when the repository is unlocked
|
||||||
// cancelling the original context also stops the lock refresh
|
// cancelling the original context also stops the lock refresh
|
||||||
func (l *locker) Lock(ctx context.Context, repo restic.Repository, exclusive bool, retryLock time.Duration, printRetry func(msg string), logger func(format string, args ...interface{})) (*Unlocker, context.Context, error) {
|
func (l *locker) Lock(ctx context.Context, repo *Repository, exclusive bool, retryLock time.Duration, printRetry func(msg string), logger func(format string, args ...interface{})) (*Unlocker, context.Context, error) {
|
||||||
|
|
||||||
lockFn := restic.NewLock
|
lockFn := restic.NewLock
|
||||||
if exclusive {
|
if exclusive {
|
||||||
|
@ -102,7 +102,7 @@ retryLoop:
|
||||||
refreshChan := make(chan struct{})
|
refreshChan := make(chan struct{})
|
||||||
forceRefreshChan := make(chan refreshLockRequest)
|
forceRefreshChan := make(chan refreshLockRequest)
|
||||||
|
|
||||||
go l.refreshLocks(ctx, repo.Backend(), lockInfo, refreshChan, forceRefreshChan, logger)
|
go l.refreshLocks(ctx, repo.be, lockInfo, refreshChan, forceRefreshChan, logger)
|
||||||
go l.monitorLockRefresh(ctx, lockInfo, refreshChan, forceRefreshChan, logger)
|
go l.monitorLockRefresh(ctx, lockInfo, refreshChan, forceRefreshChan, logger)
|
||||||
|
|
||||||
return &Unlocker{lockInfo}, ctx, nil
|
return &Unlocker{lockInfo}, ctx, nil
|
||||||
|
|
Loading…
Reference in a new issue