Skip to content
Merged
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
17 changes: 0 additions & 17 deletions cmd/ui_plugins/upload_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ui_plugins
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/fs"
Expand All @@ -15,9 +14,6 @@ import (
"strings"
)

// 100MB CLI guardrail; backend enforces the real limit
const maxBundleBytes = 100 << 20

// uploadFile is a single compiled asset to include in an asset bundle
// upload.
type uploadFile struct {
Expand Down Expand Up @@ -75,8 +71,6 @@ func collectUploadFiles(root string) ([]uploadFile, error) {
return nil, fmt.Errorf("output path %s is not a directory", root)
}

var totalSize int64
var errBundleTooLarge = errors.New("bundle exceeds upload guardrail")
var files []uploadFile
err = filepath.WalkDir(root, func(path string, d fs.DirEntry, walkErr error) error {
if walkErr != nil {
Expand All @@ -93,20 +87,9 @@ func collectUploadFiles(root string) ([]uploadFile, error) {
if err != nil {
return err
}
info, err := d.Info()
if err != nil {
return err
}
totalSize += info.Size()
if totalSize > maxBundleBytes {
return errBundleTooLarge
}
files = append(files, uploadFile{relPath: filepath.ToSlash(rel), absPath: path})
return nil
})
if errors.Is(err, errBundleTooLarge) {
return nil, fmt.Errorf("output directory %s exceeds the %d MB upload guardrail", root, maxBundleBytes>>20)
}
if err != nil {
return nil, fmt.Errorf("failed to read output directory %s: %w", root, err)
}
Expand Down
19 changes: 0 additions & 19 deletions cmd/ui_plugins/upload_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,6 @@ func TestCollectUploadFiles(t *testing.T) {
t.Fatalf("dotfiles should be skipped, got: %v", got)
}
})

t.Run("exceeds size guardrail", func(t *testing.T) {
dir := t.TempDir()
f, err := os.Create(filepath.Join(dir, "big.js"))
if err != nil {
t.Fatal(err)
}
// Sparse file: sets the reported size without writing the bytes.
if err := f.Truncate(maxBundleBytes + 1); err != nil {
f.Close()
t.Fatal(err)
}
f.Close()

_, err = collectUploadFiles(dir)
if err == nil || !strings.Contains(err.Error(), "guardrail") {
t.Fatalf("expected size-guardrail error, got: %v", err)
}
})
}

func TestContentTypeForPath(t *testing.T) {
Expand Down
Loading