Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/services/ecr/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"time"

"github.com/skyoo2003/devcloud/internal/storage/sqlite"
Expand Down Expand Up @@ -387,6 +388,15 @@ func (s *ECRStore) InitiateLayerUpload(accountID, repoName string) (string, erro

// UploadLayerPart saves layer part blob to the filesystem and records the part metadata.
func (s *ECRStore) UploadLayerPart(accountID, repoName, uploadID string, partFirst, partLast int64, blob []byte) error {
// uploadID is used as a filesystem path component; enforce generated-ID format.
// InitiateLayerUpload creates 16 random bytes encoded as 32 lowercase hex chars.
if len(uploadID) != 32 || uploadID != strings.ToLower(uploadID) {
return ErrLayerUploadNotFound
}
if _, err := hex.DecodeString(uploadID); err != nil {
return ErrLayerUploadNotFound
}

// Verify upload exists.
var exists int
_ = s.db().QueryRow(`SELECT COUNT(*) FROM layers WHERE upload_id=? AND repo_name=? AND account_id=?`, uploadID, repoName, accountID).Scan(&exists)
Expand Down
Loading