From acc0afbb7a47371e7478cc84a4ec8cd7befb11b6 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Fri, 15 Jul 2022 16:40:21 +0200 Subject: [PATCH] Remove Relative method from Locator The Relative method added to the Locator interface was not correctly implemented in the file type. The root was never set when instantiating the object. This change removes this method from the interface and the file type, switching to a local implementation in the mounts type instead. Signed-off-by: Evan Lezar --- internal/lookup/file.go | 10 ---------- internal/lookup/locator.go | 1 - 2 files changed, 11 deletions(-) diff --git a/internal/lookup/file.go b/internal/lookup/file.go index 1283f0ae..ab52d03d 100644 --- a/internal/lookup/file.go +++ b/internal/lookup/file.go @@ -28,7 +28,6 @@ import ( // prefixes. The validity of a file is determined by a filter function. type file struct { logger *log.Logger - root string prefixes []string filter func(string) error } @@ -78,15 +77,6 @@ func (p file) Locate(pattern string) ([]string, error) { return filenames, nil } -// Relative returns the path relative to the root for the file locator -func (p file) Relative(path string) (string, error) { - if p.root == "" || p.root == "/" { - return path, nil - } - - return filepath.Rel(p.root, path) -} - // assertFile checks whether the specified path is a regular file func assertFile(filename string) error { info, err := os.Stat(filename) diff --git a/internal/lookup/locator.go b/internal/lookup/locator.go index 76ade332..871e1b02 100644 --- a/internal/lookup/locator.go +++ b/internal/lookup/locator.go @@ -21,5 +21,4 @@ package lookup // Locator defines the interface for locating files on a system. type Locator interface { Locate(string) ([]string, error) - Relative(string) (string, error) }