Skip to content

Commit

Permalink
🐛 Fix deleting objects from cloud storage
Browse files Browse the repository at this point in the history
  • Loading branch information
harehare committed Oct 14, 2023
1 parent 07b2cba commit 9db10f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/.air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tmp_dir = "tmp"
[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main cmd/main.go"
cmd = "go build -o ./tmp/main cmd/api-server/main.go"
delay = 0
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
Expand Down
6 changes: 6 additions & 0 deletions backend/internal/infra/firebase/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"bytes"
"compress/gzip"
"context"
"errors"
"io"
"strings"

"cloud.google.com/go/storage"
firebaseStorage "firebase.google.com/go/v4/storage"
"github.com/samber/mo"
)
Expand Down Expand Up @@ -102,6 +104,10 @@ func (s *CloudStorage) Delete(ctx context.Context, prefix, uid, itemID string) m
}

if err = bucket.Object(getObjectName(prefix, uid, itemID)).Delete(ctx); err != nil {
if ok := errors.Is(err, storage.ErrObjectNotExist); ok {
return mo.Ok(true)
}

return mo.Err[bool](err)
}

Expand Down

0 comments on commit 9db10f9

Please sign in to comment.