From c34c0cfd461acccc780ec3824eb313305723a43c Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 10 Apr 2008 13:40:50 +0000
Subject: [PATCH] Change backend._OSSearch return values

Currently, the function backend._OSSearch() returns the (first) base dir
in which this OS can be found. Thereafter the full actual path to the OS
dir is built in the backend.OSFromDisk() function.

This patch changes this so that _OSSearch() always returns the full path
to the OS directory, and OSFromDisk uses that as returned (it will only
build it if it gets a base dir in the first place).

This patch is needed before we can abstract the _OSSearch into a generic
'look for file object' functionality that can be used for allocator
plugins search too.

Reviewed-by: ultrotter
---
 lib/backend.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index b9e8a3319..533b88396 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -979,7 +979,7 @@ def _OSSearch(name, search_path=None):
   for dir_name in search_path:
     t_os_dir = os.path.sep.join([dir_name, name])
     if os.path.isdir(t_os_dir):
-      return dir_name
+      return t_os_dir
 
   return None
 
@@ -1073,12 +1073,12 @@ def OSFromDisk(name, base_dir=None):
   """
 
   if base_dir is None:
-    base_dir = _OSSearch(name)
-
-  if base_dir is None:
-    raise errors.InvalidOS(name, None, "OS dir not found in search path")
+    os_dir = _OSSearch(name)
+    if os_dir is None:
+      raise errors.InvalidOS(name, None, "OS dir not found in search path")
+  else:
+    os_dir = os.path.sep.join([base_dir, name])
 
-  os_dir = os.path.sep.join([base_dir, name])
   api_version = _OSOndiskVersion(name, os_dir)
 
   if api_version != constants.OS_API_VERSION:
-- 
GitLab