From 3ee465d36368d7f757c726c866edfb37aff11930 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 7 Jun 2026 13:05:50 +0200 Subject: [PATCH] repository: rename Lock function to LockRepo Rename `Lock()` to `LockRepo()` to make room for the `Lock` struct. --- cmd/restic/lock.go | 2 +- internal/repository/lock.go | 2 +- internal/repository/lock_test.go | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/restic/lock.go b/cmd/restic/lock.go index 38fc79a0c..8264c6b9e 100644 --- a/cmd/restic/lock.go +++ b/cmd/restic/lock.go @@ -18,7 +18,7 @@ func internalOpenWithLocked(ctx context.Context, gopts global.Options, dryRun bo if !dryRun { var lock repository.Unlocker - lock, ctx, err = repository.Lock(ctx, repo, exclusive, gopts.RetryLock, func(msg string) { + lock, ctx, err = repository.LockRepo(ctx, repo, exclusive, gopts.RetryLock, func(msg string) { if !gopts.JSON { printer.P("%s", msg) } diff --git a/internal/repository/lock.go b/internal/repository/lock.go index d794f03e7..3267e933f 100644 --- a/internal/repository/lock.go +++ b/internal/repository/lock.go @@ -37,7 +37,7 @@ var lockerInst = &locker{ refreshabilityTimeout: restic.StaleLockTimeout - defaultRefreshInterval*3/2, } -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) { +func LockRepo(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) } diff --git a/internal/repository/lock_test.go b/internal/repository/lock_test.go index bdfb6573b..5a2813e75 100644 --- a/internal/repository/lock_test.go +++ b/internal/repository/lock_test.go @@ -76,10 +76,10 @@ func TestLockConflict(t *testing.T) { repo, be := openLockTestRepo(t, nil) repo2 := TestOpenBackend(t, be) - lock, _, err := Lock(context.Background(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {}) + lock, _, err := LockRepo(context.Background(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {}) rtest.OK(t, err) defer lock.Unlock() - _, _, err = Lock(context.Background(), repo2, false, 0, func(msg string) {}, func(format string, args ...interface{}) {}) + _, _, err = LockRepo(context.Background(), repo2, false, 0, func(msg string) {}, func(format string, args ...interface{}) {}) if err == nil { t.Fatal("second lock should have failed") } @@ -240,14 +240,14 @@ func TestLockWaitTimeout(t *testing.T) { t.Parallel() repo, _ := openLockTestRepo(t, nil) - elock, _, err := Lock(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {}) + elock, _, err := LockRepo(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {}) rtest.OK(t, err) defer elock.Unlock() retryLock := 200 * time.Millisecond start := time.Now() - _, _, err = Lock(context.TODO(), repo, false, retryLock, func(msg string) {}, func(format string, args ...interface{}) {}) + _, _, err = LockRepo(context.TODO(), repo, false, retryLock, func(msg string) {}, func(format string, args ...interface{}) {}) duration := time.Since(start) rtest.Assert(t, err != nil, @@ -262,7 +262,7 @@ func TestLockWaitCancel(t *testing.T) { t.Parallel() repo, _ := openLockTestRepo(t, nil) - elock, _, err := Lock(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {}) + elock, _, err := LockRepo(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {}) rtest.OK(t, err) defer elock.Unlock() @@ -273,7 +273,7 @@ func TestLockWaitCancel(t *testing.T) { ctx, cancel := context.WithCancel(context.TODO()) time.AfterFunc(cancelAfter, cancel) - _, _, err = Lock(ctx, repo, false, retryLock, func(msg string) {}, func(format string, args ...interface{}) {}) + _, _, err = LockRepo(ctx, repo, false, retryLock, func(msg string) {}, func(format string, args ...interface{}) {}) duration := time.Since(start) rtest.Assert(t, err != nil, @@ -288,7 +288,7 @@ func TestLockWaitSuccess(t *testing.T) { t.Parallel() repo, _ := openLockTestRepo(t, nil) - elock, _, err := Lock(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {}) + elock, _, err := LockRepo(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {}) rtest.OK(t, err) retryLock := 200 * time.Millisecond @@ -298,7 +298,7 @@ func TestLockWaitSuccess(t *testing.T) { elock.Unlock() }) - lock, _, err := Lock(context.TODO(), repo, false, retryLock, func(msg string) {}, func(format string, args ...interface{}) {}) + lock, _, err := LockRepo(context.TODO(), repo, false, retryLock, func(msg string) {}, func(format string, args ...interface{}) {}) rtest.OK(t, err) lock.Unlock() }