diff --git a/pkg/channels/wecom/media.go b/pkg/channels/wecom/media.go index 974a3bf4..1494b579 100644 --- a/pkg/channels/wecom/media.go +++ b/pkg/channels/wecom/media.go @@ -334,7 +334,7 @@ func (c *WeComChannel) storeRemoteMedia( } tmpPath := tmpFile.Name() if _, writeErr := tmpFile.Write(data); writeErr != nil { - tmpFile.Close() + _ = tmpFile.Close() _ = os.Remove(tmpPath) return "", fmt.Errorf("write temp file: %w", writeErr) } diff --git a/pkg/tools/fs/filesystem.go b/pkg/tools/fs/filesystem.go index 4911b0fa..4b7a7ca3 100644 --- a/pkg/tools/fs/filesystem.go +++ b/pkg/tools/fs/filesystem.go @@ -1111,7 +1111,7 @@ func (r *sandboxFs) WriteFile(path string, data []byte) error { } if _, err := tmpFile.Write(data); err != nil { - tmpFile.Close() + _ = tmpFile.Close() root.Remove(tmpRelPath) return fmt.Errorf("failed to write temp file: %w", err) } @@ -1119,7 +1119,7 @@ func (r *sandboxFs) WriteFile(path string, data []byte) error { // CRITICAL: Force sync to storage medium before rename. // This ensures data is physically written to disk, not just cached. if err := tmpFile.Sync(); err != nil { - tmpFile.Close() + _ = tmpFile.Close() root.Remove(tmpRelPath) return fmt.Errorf("failed to sync temp file: %w", err) } diff --git a/pkg/tools/normalization.go b/pkg/tools/normalization.go index 3a76c5d9..7ced32bb 100644 --- a/pkg/tools/normalization.go +++ b/pkg/tools/normalization.go @@ -230,7 +230,7 @@ func storeInlineDataURL( } tmpPath := tmpFile.Name() if _, err = tmpFile.Write(decoded); err != nil { - tmpFile.Close() + _ = tmpFile.Close() _ = os.Remove(tmpPath) return "", fmt.Sprintf("[Tool returned inline media content (%s) but it could not be stored.]", mimeType) }