Files
zot/pkg/extensions/sync/stream_temp_store.go
T
Vishwas Rajashekar e2aa088e0d feat(sync): initial commit for streaming sync
initial working prototype for sync

fix: pre-load chunk readers on manifest fetch

feat: make chunkSize configurable

fix minimal build

fix: linter errors

Signed-off-by: Vishwas Rajashekar <dev@vrajashkr.com>
2026-05-22 17:40:25 +05:30

50 lines
1013 B
Go

package sync
import (
"errors"
"fmt"
"os"
"path"
godigest "github.com/opencontainers/go-digest"
)
type StreamTempStore interface {
BlobPath(digest godigest.Digest) string
}
type LocalTempStore struct {
rootPath string
}
func NewLocalTempStore(rootDir string) *LocalTempStore {
_, err := os.Stat(rootDir)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
err := os.MkdirAll(rootDir, 0o755)
if err != nil {
fmt.Println("failed to create root dir " + err.Error())
}
} else {
fmt.Println("failed to stat root dir " + err.Error())
}
}
return &LocalTempStore{
rootPath: rootDir,
}
}
func (lts *LocalTempStore) BlobPath(digest godigest.Digest) string {
parentDir := path.Join(lts.rootPath, digest.Algorithm().String())
_, err := os.Stat(parentDir)
if err != nil && errors.Is(err, os.ErrNotExist) {
err := os.MkdirAll(parentDir, 0o755)
if err != nil {
fmt.Println("failed to create directory " + err.Error())
}
}
return path.Join(parentDir, digest.Encoded())
}