From f31a6deeeeb896cc516c2f2f91ceff1fd0702938 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 25 Apr 2016 10:03:38 -0700 Subject: [PATCH] target_files_diff: Fix the issue with file type change. When a file is switched from a regular file to a symlink, we should skip the comparasion. Bug: 28373409 Change-Id: I8fef00ab9f2d6f811fde1cadf595e8bd46af2dfd --- tools/releasetools/target_files_diff.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/releasetools/target_files_diff.py b/tools/releasetools/target_files_diff.py index 196d2e887..0f717e0b9 100755 --- a/tools/releasetools/target_files_diff.py +++ b/tools/releasetools/target_files_diff.py @@ -172,17 +172,16 @@ def recursiveDiff(prefix, dir1, dir2, out_file): continue if entry in list2: - if os.path.islink(name1): - if os.path.islink(name2): - link1 = os.readlink(name1) - link2 = os.readlink(name2) - if link1 != link2: - print("%s: Symlinks differ: %s vs %s" % (name, link1, link2), - file=out_file) - else: - print("%s: File types differ, skipping compare" % name, + if os.path.islink(name1) and os.path.islink(name2): + link1 = os.readlink(name1) + link2 = os.readlink(name2) + if link1 != link2: + print("%s: Symlinks differ: %s vs %s" % (name, link1, link2), file=out_file) continue + elif os.path.islink(name1) or os.path.islink(name2): + print("%s: File types differ, skipping compare" % name, file=out_file) + continue stat1 = os.stat(name1) stat2 = os.stat(name2) -- 2.11.0