Skip to content

Commit

Permalink
Give better message when source files are missing
Browse files Browse the repository at this point in the history
If source files are missing from the system which are in the plist
file we should write out the missing file paths too.
  • Loading branch information
csordasmarton committed May 2, 2018
1 parent 07c5a34 commit 1ae83cd
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions libcodechecker/libhandlers/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,21 +187,32 @@ def assemble_zip(inputs, zip_file, client):
# but different path.
file_to_hash = {}
file_to_mtime = {}
missing_source_files = set()

def collect_file_hashes_from_plist(plist_file):
"""
Collects file content hashes and last modification times of files which
can be found in the given plist file.
:returns List of file paths which are in the processed plist file but
missing from the user's disk.
"""
missing_files = []
try:
files, _ = plist_parser.parse_plist(plist_file)

for f in files:
if not os.path.isfile(f):
return False
missing_files.append(f)
missing_source_files.add(f)
continue

content_hash = util.get_file_content_hash(f)
hash_to_file[content_hash] = f
file_to_hash[f] = content_hash
file_to_mtime[f] = util.get_last_mod_time(f)

return True
return missing_files
except Exception as ex:
LOG.error('Parsing the plist failed: ' + str(ex))

Expand All @@ -223,15 +234,16 @@ def collect_file_hashes_from_plist(plist_file):
for f in files:
plist_file = os.path.join(input_path, f)
if f.endswith(".plist"):
if collect_file_hashes_from_plist(plist_file):
missing_files = collect_file_hashes_from_plist(plist_file)
if not missing_files:
LOG.debug(
"Copying file '{0}' to ZIP assembly dir..."
.format(plist_file))
plist_report_files.append(os.path.join(input_path, f))
else:
LOG.warning("Skipping '{0}' because it contains "
"a missing source file."
.format(plist_file))
LOG.warning("Skipping '%s' because it refers "
"the following missing source files: %s",
plist_file, missing_files)
elif f == 'metadata.json':
plist_report_files.append(os.path.join(input_path, f))

Expand Down Expand Up @@ -278,6 +290,10 @@ def collect_file_hashes_from_plist(plist_file):

LOG.debug("[ZIP] Mass store zip written at '{0}'".format(zip_file))

if missing_source_files:
LOG.warning("Missing source files: \n%s", '\n'.join(
map(lambda f_: " - " + f_, missing_source_files)))


def main(args):
"""
Expand Down

0 comments on commit 1ae83cd

Please sign in to comment.