From e6601c725ba4d98c0bc4ccf6b00c32b3bea02a8e Mon Sep 17 00:00:00 2001 From: lasith-kg Date: Wed, 3 Jan 2024 09:49:20 +0000 Subject: [PATCH] (feat): Skip mount point quuerying if not provided --- internal/backend/file.go | 3 +++ internal/backend/file_test.go | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/internal/backend/file.go b/internal/backend/file.go index b1f41ff..3318996 100644 --- a/internal/backend/file.go +++ b/internal/backend/file.go @@ -94,6 +94,9 @@ func (lfb *LinuxFileBackend) From(config *config.Config) error { files := map[string]*model.File{} for _, cd := range config.Devices { + if len(cd.MountPoint) == 0 { + continue + } // For certain file operations (like lfb.IsMount()) it is essential // that we can query the parent directory. Therefore, lets pull the // state of the parent directory of the mount point diff --git a/internal/backend/file_test.go b/internal/backend/file_test.go index b781fd4..535aa10 100644 --- a/internal/backend/file_test.go +++ b/internal/backend/file_test.go @@ -366,6 +366,16 @@ func TestLinuxFileBackendFrom(t *testing.T) { }, ExpectedError: nil, }, + { + Name: "Skip + No Mount Point Provided", + Config: &config.Config{ + Devices: map[string]config.Device{ + "/dev/xvdf": {}, + }, + }, + ExpectedOutput: map[string]*model.File{}, + ExpectedError: nil, + }, { Name: "Failure to Retrieve File Information", Config: &config.Config{