Skip to content

Commit

Permalink
Add 'Exists' method to storage backends (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
irees authored Jul 28, 2023
1 parent 840cee3 commit d2157e2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tl/request/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit d2157e2

Please sign in to comment.