summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-09-14 15:42:44 +1200
committerPaul Eggleton <paul.eggleton@linux.intel.com>2017-09-14 15:52:21 +1200
commit9123c287db12b826cea69f8270f3635efd205a0c (patch)
treebb1a5829f5707bf4a7348ae73067aa486d51617b
parent1b209b6f3a50fa0ce79f3f568401c80f1a0d41ce (diff)
downloadbitbake-contrib-9123c287db12b826cea69f8270f3635efd205a0c.tar.gz
cooker: ensure monkey-patching in collect_bbfiles() gets undone on errorpaule/bb-watch-fixes
In collect_bbfiles() we're monkey-patching os.listdir in order to find which directories to watch, and then undoing that when we're finished - however if an exception occurred for any reason there was nothing to ensure the latter occurred. This may not have caused any issues, but as this kind of thing really ought to be secured using try...finally just in case, so do that. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rw-r--r--lib/bb/cooker.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 6de04fcba..73a2fef28 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -1695,25 +1695,25 @@ class CookerCollectFiles(object):
return origlistdir(d)
os.listdir = ourlistdir
-
- # Can't use set here as order is important
- newfiles = []
- for f in files:
- if os.path.isdir(f):
- dirfiles = self.find_bbfiles(f)
- for g in dirfiles:
- if g not in newfiles:
- newfiles.append(g)
- else:
- globbed = glob.glob(f)
- if not globbed and os.path.exists(f):
- globbed = [f]
- # glob gives files in order on disk. Sort to be deterministic.
- for g in sorted(globbed):
- if g not in newfiles:
- newfiles.append(g)
-
- os.listdir = origlistdir
+ try:
+ # Can't use set here as order is important
+ newfiles = []
+ for f in files:
+ if os.path.isdir(f):
+ dirfiles = self.find_bbfiles(f)
+ for g in dirfiles:
+ if g not in newfiles:
+ newfiles.append(g)
+ else:
+ globbed = glob.glob(f)
+ if not globbed and os.path.exists(f):
+ globbed = [f]
+ # glob gives files in order on disk. Sort to be deterministic.
+ for g in sorted(globbed):
+ if g not in newfiles:
+ newfiles.append(g)
+ finally:
+ os.listdir = origlistdir
bbmask = config.getVar('BBMASK')