summaryrefslogtreecommitdiff
path: root/internal/client/output/b2.go
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'internal/client/output/b2.go')
-rw-r--r--internal/client/output/b2.go17
1 files changed, 4 insertions, 13 deletions
diff --git a/internal/client/output/b2.go b/internal/client/output/b2.go
index 0616368..6979e5b 100644
--- a/internal/client/output/b2.go
+++ b/internal/client/output/b2.go
@@ -2,10 +2,9 @@ package output
import (
"context"
- "encoding/json"
"fmt"
"io"
- "log/slog"
+ "strconv"
"github.com/Backblaze/blazer/b2"
"github.com/SayaAndy/saya-today-thumbnail-generator/config"
@@ -20,7 +19,7 @@ type B2OutputClient struct {
b2cl *b2.Client
}
-func NewB2OutputClient(cfg *config.OutputConfig) (OutputClient, error) {
+func NewB2OutputClient(cfg *config.OutputConfig) (*B2OutputClient, error) {
if cfg.Storage.Type != "b2" {
return nil, fmt.Errorf("invalid storage type for B2OutputClient")
}
@@ -39,7 +38,7 @@ func NewB2OutputClient(cfg *config.OutputConfig) (OutputClient, error) {
return &B2OutputClient{b2cl: b2cl, bucket: bucket, prefix: b2cfg.Prefix}, nil
}
-func (c *B2OutputClient) GetWriter(path string, inputMetadata *input.MetadataStruct, outputContentType string) (io.WriteCloser, error) {
+func (c *B2OutputClient) GetWriter(path string, inputMetadata *input.MetadataStruct) (io.WriteCloser, error) {
obj := c.bucket.Object(c.prefix + path)
if obj == nil {
return nil, fmt.Errorf("failed to reference object in B2 bucket")
@@ -47,7 +46,6 @@ func (c *B2OutputClient) GetWriter(path string, inputMetadata *input.MetadataStr
attrs := &b2.Attrs{Info: make(map[string]string)}
attrs.Info["sha1-original"] = inputMetadata.Hash
- attrs.ContentType = outputContentType
return obj.NewWriter(context.Background(), b2.WithAttrsOption(attrs)), nil
}
@@ -72,8 +70,8 @@ func (c *B2OutputClient) ReadMetadata(path string) (*MetadataStruct, error) {
FirstCreated: attrs.UploadTimestamp,
LastModified: attrs.LastModified,
Misc: attrs.Info,
- Size: attrs.Size,
}
+ metadata.Misc["Size"] = strconv.FormatInt(attrs.Size, 10)
switch attrs.Status {
case b2.Uploaded:
@@ -102,12 +100,5 @@ func (c *B2OutputClient) IsMissing(path string) bool {
return true
}
- attrsJson, _ := json.Marshal(attrs)
- slog.Debug("got object attrs", slog.String("path", path), slog.String("attrs", string(attrsJson)))
-
- if attrs.Size == 0 {
- return true
- }
-
return attrs.Status == b2.Hider
}