Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 12 additions & 4 deletions pkg/distribution/internal/store/blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package store
import (
"context"
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"errors"
"fmt"
"hash"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -276,14 +278,20 @@ func (s *LocalStore) WriteBlobWithResume(diffID oci.Hash, r io.Reader, digestStr
// We hash the whole file rather than the streamed bytes so that resumed
// downloads (which append to an existing partial file) are verified
// correctly over their entire contents.
if diffID.Algorithm == "sha256" {
var hasher hash.Hash
switch diffID.Algorithm {
case "sha256":
hasher = sha256.New()
Copy link
Copy Markdown
Contributor

@sathiraumesh sathiraumesh Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion, It may be better to move this to a separate function like

hasher(string algo) (has.Hash){
...
}

case "sha512":
hasher = sha512.New()
}
if hasher != nil {
completedFile, openErr := os.Open(incompletePath)
if openErr != nil {
_ = os.Remove(incompletePath)
return fmt.Errorf("open completed blob file for verification: %w", openErr)
}

hasher := sha256.New()
if _, copyErr := io.Copy(hasher, completedFile); copyErr != nil {
completedFile.Close()
_ = os.Remove(incompletePath)
Expand All @@ -294,8 +302,8 @@ func (s *LocalStore) WriteBlobWithResume(diffID oci.Hash, r io.Reader, digestStr
computed := hex.EncodeToString(hasher.Sum(nil))
if computed != diffID.Hex {
_ = os.Remove(incompletePath)
return fmt.Errorf("blob digest mismatch for %q: expected sha256:%s, got sha256:%s",
diffID.String(), diffID.Hex, computed)
return fmt.Errorf("blob digest mismatch for %q: expected %s:%s, got %s:%s",
diffID.String(), diffID.Algorithm, diffID.Hex, diffID.Algorithm, computed)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/inference/backends/diffusers/diffusers.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (d *diffusers) Run(ctx context.Context, socket, model string, modelRef stri
BackendName: "Diffusers",
Socket: socket,
BinaryPath: d.pythonPath,
SandboxPath: "",
SandboxPath: filepath.Dir(d.pythonPath),
SandboxConfig: sandbox.ConfigurationPython,
Args: args,
Logger: d.log,
Expand Down
3 changes: 2 additions & 1 deletion pkg/inference/backends/mlx/mlx.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os/exec"
"path/filepath"
"strings"

"github.com/docker/model-runner/pkg/inference"
Expand Down Expand Up @@ -140,7 +141,7 @@ func (m *mlx) Run(ctx context.Context, socket, model string, modelRef string, mo
BackendName: "MLX",
Socket: socket,
BinaryPath: m.pythonPath,
SandboxPath: "",
SandboxPath: filepath.Dir(m.pythonPath),
SandboxConfig: sandbox.ConfigurationPython,
Args: args,
Logger: m.log,
Expand Down
2 changes: 1 addition & 1 deletion pkg/inference/backends/vllm/vllm_metal.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (v *vllmMetal) Run(ctx context.Context, socket, model string, modelRef stri
BackendName: "vllm-metal",
Socket: socket,
BinaryPath: v.pythonPath,
SandboxPath: v.installDir,
SandboxPath: filepath.Join(v.installDir, "bin"),
SandboxConfig: sandbox.ConfigurationPython,
Args: args,
Logger: v.log,
Expand Down
Loading