in pcap-fsnotify/internal/gcs/fuse_exporter.go [66:117]
func (x *fuseExporter) Export(
ctx context.Context,
srcPcapFile *string,
compress bool,
delete bool,
) (*string, *int64, error) {
tgtPcapFile := x.toTargetPcapFile(srcPcapFile, compress)
var pcapBytes int64 = 0
// Create destination PCAP file ( when using Fuse this is the same as exporting to the GCS Bucket )
pcapFileWriter, err := x.newFile(srcPcapFile, &tgtPcapFile)
if err != nil {
x.logger.LogFsEvent(
zapcore.ErrorLevel,
sf.Format("failed to CREATE file: {0}", tgtPcapFile),
PCAP_EXPORT,
*srcPcapFile,
tgtPcapFile,
0,
err)
return &tgtPcapFile, &pcapBytes, errors.Wrap(err,
sf.Format("failed to create destination pcap: {0}", tgtPcapFile))
}
// x.logger.logFsEvent(zapcore.InfoLevel, fmt.Sprintf("CREATED: %s", tgtPcap), PCAP_EXPORT, *srcPcap, tgtPcap, 0)
pcapBytes, err = retry.DoWithData(func() (int64, error) {
// Copy source PCAP into destination PCAP directory, compressing destination PCAP is optional
return x.export(srcPcapFile, &tgtPcapFile, pcapFileWriter, compress, delete, x.onExported)
},
retry.Context(ctx),
retry.Attempts(x.maxRetries),
retry.Delay(x.retriesDelay),
retry.DelayType(retry.FixedDelay),
retry.OnRetry(func(attempt uint, err error) {
x.logger.LogEvent(
zapcore.WarnLevel,
sf.Format(
"failed to COPY file at attempt {0}: {1}",
attempt+1, *srcPcapFile,
),
PCAP_EXPORT,
map[string]any{
"source": *srcPcapFile,
"target": tgtPcapFile,
"attempt": attempt + 1,
},
err)
}))
return &tgtPcapFile, &pcapBytes, nil
}