From 980aa20a0631806fddab2e6a02bc9391de55afb3 Mon Sep 17 00:00:00 2001 From: Preslav Gerchev Date: Wed, 29 Jan 2025 11:38:34 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Do=20not=20store=20duplicate=20m?= =?UTF-8?q?ountpoints.=20(#5126)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Preslav --- providers/os/connection/device/device_connection.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/providers/os/connection/device/device_connection.go b/providers/os/connection/device/device_connection.go index 428ae466b4..c766de8d73 100644 --- a/providers/os/connection/device/device_connection.go +++ b/providers/os/connection/device/device_connection.go @@ -119,7 +119,10 @@ func NewDeviceConnection(connId uint32, conf *inventory.Config, asset *inventory } block.MountPoint = scanDir } - res.MountedDirs = append(res.MountedDirs, block.MountPoint) + if !stringx.Contains(res.MountedDirs, block.MountPoint) { + res.MountedDirs = append(res.MountedDirs, block.MountPoint) + } + res.partitions[block.MountPoint] = block if asset.Platform != nil { @@ -236,14 +239,12 @@ func tryDetectAsset(connId uint32, partition *snapshot.PartitionInfo, conf *inve fingerprint, p, err := id.IdentifyPlatform(fsConn, &plugin.ConnectReq{}, p, asset.IdDetector) if err != nil { if len(asset.PlatformIds) == 0 { - log.Debug().Err(err). - Msg("device connection> failed to identify platform from device") + log.Debug().Err(err).Msg("device connection> failed to identify platform from device") return nil, err } - - log.Warn().Err(err). - Msg("device connection> failed to identify platform from device, using existing platform ids") + log.Warn().Err(err).Msg("device connection> cannot detect platform ids, using existing ones") } + if p == nil { log.Debug().Msg("device connection> no platform detected") return nil, errors.New("device connection> no platform detected")