don't error out if storage key already exists (#840)

This commit is contained in:
tobi 2022-09-19 13:59:11 +02:00 committed by GitHub
commit de26924a4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 6 deletions

View file

@ -24,6 +24,7 @@ import (
"net/url"
"codeberg.org/gruf/go-store/kv"
"codeberg.org/gruf/go-store/storage"
)
type Local struct {
@ -39,11 +40,19 @@ func (l *Local) GetStream(ctx context.Context, key string) (io.ReadCloser, error
}
func (l *Local) PutStream(ctx context.Context, key string, r io.Reader) error {
return l.KVStore.PutStream(key, r)
err := l.KVStore.PutStream(key, r)
if err == storage.ErrAlreadyExists {
return ErrAlreadyExists
}
return err
}
func (l *Local) Put(ctx context.Context, key string, value []byte) error {
return l.KVStore.Put(key, value)
err := l.KVStore.Put(key, value)
if err == storage.ErrAlreadyExists {
return ErrAlreadyExists
}
return err
}
func (l *Local) Delete(ctx context.Context, key string) error {

View file

@ -34,6 +34,7 @@ import (
)
var ErrNotSupported = errors.New("driver does not suppport functionality")
var ErrAlreadyExists = errors.New("storage key already exists")
// Driver implements the functionality to store and retrieve blobs
// (images,video,audio)