From 80632dd1d9495f53ceb729dd007e389a79115f04 Mon Sep 17 00:00:00 2001 From: afranco Date: Sun, 12 Oct 2025 12:03:33 +0100 Subject: [PATCH] fix(pcap): try to fix file handle error --- internal/qol/capture/pcap.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/qol/capture/pcap.go b/internal/qol/capture/pcap.go index 205a990..925309f 100644 --- a/internal/qol/capture/pcap.go +++ b/internal/qol/capture/pcap.go @@ -31,8 +31,12 @@ func NewPacketCapture(iface, outputPath string) (*PacketCapture, error) { fileExists = true } - // Open in append mode - file, err := os.OpenFile(outputPath, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644) + var file *os.File + if fileExists { + file, err = os.OpenFile(outputPath, os.O_APPEND, 0644) + } else { + file, err = os.Create(outputPath) + } if err != nil { handle.Close() return nil, fmt.Errorf("create/open pcap file: %w", err)