From d2157e2314ec127e24a229554410ea7eb61df53b Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Thu, 27 Jul 2023 17:13:31 -0700 Subject: [PATCH] Add 'Exists' method to storage backends (#271) --- tl/request/local.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tl/request/local.go b/tl/request/local.go index 4ca35ea3..3689a335 100644 --- a/tl/request/local.go +++ b/tl/request/local.go @@ -29,3 +29,12 @@ func (r Local) Upload(ctx context.Context, key string, secret tl.Secret, uploadF _, err = io.Copy(out, uploadFile) return err } + +func (r Local) Exists(ctx context.Context, key string) bool { + fn := filepath.Join(r.Directory, key) + info, err := os.Stat(fn) + if os.IsNotExist(err) { + return false + } + return !info.IsDir() +}