Skip to content

Commit 38faf8c

Browse files
committed
refactor(package): consolidate cleanup of temporary tar files
1 parent 0d8e66a commit 38faf8c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cmd/cli/commands/package.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,13 @@ func packageModel(cmd *cobra.Command, opts packageOptions) error {
218218
// Process directory tar archives
219219
var tempDirTarFiles []string
220220
if len(opts.dirTarPaths) > 0 {
221+
// Schedule cleanup of temp tar files
222+
defer func() {
223+
for _, tempFile := range tempDirTarFiles {
224+
os.Remove(tempFile)
225+
}
226+
}()
227+
221228
// Determine base directory for resolving relative paths
222229
var baseDir string
223230
if opts.safetensorsDir != "" {
@@ -262,13 +269,6 @@ func packageModel(cmd *cobra.Command, opts packageOptions) error {
262269
return fmt.Errorf("add directory tar: %w", err)
263270
}
264271
}
265-
266-
// Schedule cleanup of temp tar files after build completes
267-
defer func() {
268-
for _, tempFile := range tempDirTarFiles {
269-
os.Remove(tempFile)
270-
}
271-
}()
272272
}
273273

274274
if opts.push {

0 commit comments

Comments
 (0)