summaryrefslogtreecommitdiff
path: root/internal/storage
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-09-19 13:59:11 +0200
committerLibravatar GitHub <noreply@github.com>2022-09-19 12:59:11 +0100
commitde26924a4a47fa6b48971cf51f51a5b732745e59 (patch)
treeac667f5a5089bbe832bba78fb0cf019075863d4c /internal/storage
parent[bugfix] Server and closer bugfixes (#839) (diff)
downloadgotosocial-de26924a4a47fa6b48971cf51f51a5b732745e59.tar.xz
don't error out if storage key already exists (#840)
Diffstat (limited to 'internal/storage')
-rw-r--r--internal/storage/local.go13
-rw-r--r--internal/storage/storage.go1
2 files changed, 12 insertions, 2 deletions
diff --git a/internal/storage/local.go b/internal/storage/local.go
index 8ed3ca8d8..103233219 100644
--- a/internal/storage/local.go
+++ b/internal/storage/local.go
@@ -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 {
diff --git a/internal/storage/storage.go b/internal/storage/storage.go
index 7a4ebc6c3..7bd4c18aa 100644
--- a/internal/storage/storage.go
+++ b/internal/storage/storage.go
@@ -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)