Skip to content

Commit 5197817

Browse files
committed
review
1 parent c1efd7b commit 5197817

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

cmd/extensions.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,18 @@ func (e ExtensionsCmd) Upload(ctx context.Context, in ExtensionsUploadInput) err
320320
}
321321
defer os.Remove(tmpFile)
322322

323-
// Show helpful stats
323+
// Get zip file size
324+
fileInfo, err := os.Stat(tmpFile)
325+
if err != nil {
326+
return fmt.Errorf("failed to stat zip: %w", err)
327+
}
328+
324329
if in.Output != "json" {
325330
pterm.Success.Printf("Created bundle: %s (%d files)\n",
326-
util.FormatBytes(stats.BytesIncluded), stats.FilesIncluded)
331+
util.FormatBytes(fileInfo.Size()), stats.FilesIncluded)
327332
}
328333

329334
// Final size validation
330-
fileInfo, err := os.Stat(tmpFile)
331-
if err != nil {
332-
return fmt.Errorf("failed to stat zip: %w", err)
333-
}
334335

335336
if fileInfo.Size() > MaxExtensionSize {
336337
pterm.Error.Printf("Extension bundle is too large: %s (max: 50MB)\n",

pkg/util/zip_extensions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func ZipExtensionDirectory(srcDir, destZip string, opts *ExtensionZipOptions) (*
105105
walker.ExcludeFilename = append(walker.ExcludeFilename, DefaultExtensionExclusions.ExcludeFilenamePatterns...)
106106
}
107107

108+
// Ensure walker is terminated on any return path to prevent goroutine leak
109+
defer walker.Terminate()
110+
108111
// Track walker errors
109112
errChan := make(chan error, 1)
110113
go func() {

0 commit comments

Comments
 (0)