Files
cluster/handler/blob_handler.go
2025-11-09 15:19:11 +08:00

38 lines
987 B
Go

package handler
import (
"context"
"io"
"gitea.loveuer.com/loveuer/cluster/internal/model"
"gitea.loveuer.com/loveuer/cluster/internal/registry/storage"
)
type blobHandlerImpl struct {
store storage.Storage
}
// NewBlobHandler creates a new blob handler
func NewBlobHandler(store storage.Storage) BlobHandler {
return &blobHandlerImpl{store: store}
}
func (b *blobHandlerImpl) Get(ctx context.Context, repo string, h model.Hash) (io.ReadCloser, error) {
reader, _, err := b.store.GetBlob(repo, h.String())
return reader, err
}
func (b *blobHandlerImpl) Put(ctx context.Context, repo string, h model.Hash, rc io.ReadCloser) error {
defer rc.Close()
return b.store.PutBlob(repo, h.String(), rc)
}
func (b *blobHandlerImpl) Stat(ctx context.Context, repo string, h model.Hash) (int64, error) {
return b.store.GetBlobSize(repo, h.String())
}
func (b *blobHandlerImpl) Delete(ctx context.Context, repo string, h model.Hash) error {
// TODO: implement delete
return nil
}