From 7c20e483d923255953791b217f48c323d14c69ac Mon Sep 17 00:00:00 2001 From: Mikita Iwanowski Date: Wed, 23 Oct 2024 14:55:53 +0200 Subject: [PATCH] simplify search (start with 0) --- providers/os/connection/snapshot/blockdevices.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/providers/os/connection/snapshot/blockdevices.go b/providers/os/connection/snapshot/blockdevices.go index 88deb09847..c567577257 100644 --- a/providers/os/connection/snapshot/blockdevices.go +++ b/providers/os/connection/snapshot/blockdevices.go @@ -110,6 +110,11 @@ func (blockEntries *BlockDevices) findAlias(alias, path string) { for i := range blockEntries.BlockDevices { device := blockEntries.BlockDevices[i] if alias == device.Name { + log.Debug(). + Str("alias", alias). + Str("path", path). + Str("name", device.Name). + Msg("found alias") device.Aliases = append(device.Aliases, path) blockEntries.BlockDevices[i] = device return @@ -216,11 +221,11 @@ func (blockEntries BlockDevices) FindDevice(requested string) (BlockDevice, erro Device BlockDevice Lms int }{ - Device: devices[0], - Lms: LongestMatchingSuffix(requested, devices[0].Name), + Device: BlockDevice{}, + Lms: 0, } - for i := 1; i < len(devices); i++ { + for i := 0; i < len(devices); i++ { log.Debug(). Str("name", devices[i].Name). Strs("aliases", devices[i].Aliases).