diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2017-12-22 11:44:43 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2017-12-22 11:44:43 +0000 |
commit | fc665e4410ed36c52f02610de634adc0acff38f5 (patch) | |
tree | 4241e253e48c22eb9dbbdc5e42f14ccfe15bb91e | |
parent | 30d5a029e4ca99c925141fd0fe3e46ae73846608 (diff) | |
download | buildstream-fc665e4410ed36c52f02610de634adc0acff38f5.tar.gz |
utils.py: _process_list(): Check if file is missing as first thing
The first thing we do should be to check if the file is missing, as
we can short circuit the whole rest of the code in that case.
-rw-r--r-- | buildstream/utils.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/buildstream/utils.py b/buildstream/utils.py index c624c9faa..7d898bd4c 100644 --- a/buildstream/utils.py +++ b/buildstream/utils.py @@ -554,6 +554,17 @@ def _process_list(srcdir, destdir, filelist, actionfunc, result, ignore_missing= srcpath = os.path.join(srcdir, path) destpath = os.path.join(destdir, path) + try: + file_stat = os.lstat(srcpath) + mode = file_stat.st_mode + + except FileNotFoundError as e: + # Skip this missing file + if ignore_missing: + continue + else: + raise UtilError("Source file is missing: {}".format(srcpath)) + # Collect overlaps if os.path.lexists(destpath) and not os.path.isdir(destpath): result.overwritten.append(path) @@ -566,17 +577,6 @@ def _process_list(srcdir, destdir, filelist, actionfunc, result, ignore_missing= # symlink boundaries _ensure_real_directory(os.path.dirname(destpath)) - try: - file_stat = os.lstat(srcpath) - mode = file_stat.st_mode - - except FileNotFoundError as e: - # Skip this missing file - if ignore_missing: - continue - else: - raise UtilError("Source file is missing: {}".format(srcpath)) - if stat.S_ISDIR(mode): # Ensure directory exists in destination if not os.path.exists(destpath): |