Skip to content

Commit a3e1159

Browse files
fix: restore CleanUpload method and call for proper resource cleanup
The previous refactor (removing --no-delete-upload) accidentally removed the CleanUpload method and its call in ExecuteCleanMethod. This caused the SMB file writer handle registered in FileStager.Upload() to never be closed. Restored: - CleanUpload method on ExecutionIO (closes provider resources) - CleanUpload call in ExecuteCleanMethod (after upload + confirm) Co-authored-by: Carter <carter-falconops@users.noreply.github.com>
1 parent 8708171 commit a3e1159

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

pkg/goexec/io.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ func (execIO *ExecutionIO) DoUpload(ctx context.Context) (err error) {
6262
return nil
6363
}
6464

65+
func (execIO *ExecutionIO) CleanUpload(ctx context.Context) (err error) {
66+
if execIO.Upload != nil && execIO.Upload.Provider != nil {
67+
return execIO.Upload.Provider.Clean(ctx)
68+
}
69+
return nil
70+
}
71+
6572
func (execIO *ExecutionIO) GetOutput(ctx context.Context) (err error) {
6673
if execIO.Output.Provider != nil {
6774
ctx = context.WithValue(ctx, ContextOptionOutputTimeout, execIO.Output.Timeout)

pkg/goexec/method.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ func ExecuteCleanMethod(ctx context.Context, module CleanExecutionMethod, execIO
131131
}
132132
}
133133
}
134+
// Clean up upload provider resources (close file handles)
135+
if cleanErr := execIO.CleanUpload(ctx); cleanErr != nil {
136+
log.Debug().Err(cleanErr).Msg("Upload cleanup failed")
137+
}
134138
}
135139

136140
// Execute (only if a command/executable was provided)

0 commit comments

Comments
 (0)