mirror of
https://github.com/octoleo/restic.git
synced 2024-12-03 10:28:27 +00:00
lock: Use repository interface instead of struct
This commit is contained in:
parent
d92957dd78
commit
c3538b063a
@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"github.com/restic/restic/internal/debug"
|
"github.com/restic/restic/internal/debug"
|
||||||
"github.com/restic/restic/internal/errors"
|
"github.com/restic/restic/internal/errors"
|
||||||
"github.com/restic/restic/internal/repository"
|
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,17 +21,17 @@ var globalLocks struct {
|
|||||||
sync.Once
|
sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
func lockRepo(ctx context.Context, repo *repository.Repository) (*restic.Lock, context.Context, error) {
|
func lockRepo(ctx context.Context, repo restic.Repository) (*restic.Lock, context.Context, error) {
|
||||||
return lockRepository(ctx, repo, false)
|
return lockRepository(ctx, repo, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func lockRepoExclusive(ctx context.Context, repo *repository.Repository) (*restic.Lock, context.Context, error) {
|
func lockRepoExclusive(ctx context.Context, repo restic.Repository) (*restic.Lock, context.Context, error) {
|
||||||
return lockRepository(ctx, repo, true)
|
return lockRepository(ctx, repo, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// lockRepository wraps the ctx such that it is cancelled when the repository is unlocked
|
// lockRepository 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 lockRepository(ctx context.Context, repo *repository.Repository, exclusive bool) (*restic.Lock, context.Context, error) {
|
func lockRepository(ctx context.Context, repo restic.Repository, exclusive bool) (*restic.Lock, context.Context, error) {
|
||||||
// make sure that a repository is unlocked properly and after cancel() was
|
// make sure that a repository is unlocked properly and after cancel() was
|
||||||
// called by the cleanup handler in global.go
|
// called by the cleanup handler in global.go
|
||||||
globalLocks.Do(func() {
|
globalLocks.Do(func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user