diff --git a/cmd/restic/cmd_check.go b/cmd/restic/cmd_check.go index 7bea641ae..83ebf89a6 100644 --- a/cmd/restic/cmd_check.go +++ b/cmd/restic/cmd_check.go @@ -199,10 +199,7 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args } cleanup := prepareCheckCache(opts, &gopts) - AddCleanupHandler(func(code int) (int, error) { - cleanup() - return code, nil - }) + defer cleanup() if !gopts.NoLock { Verbosef("create exclusive lock for repository\n")