From 4230533310d8d8d049db72b6bd0f3b33d6572ff0 Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Wed, 9 Feb 2022 12:15:47 +0100 Subject: [PATCH] Load all files that can be decoded from a zip Even if some failures occur. For example, a zip file with an mp4 recorded via MediaProjection doesn't include the winscope metadata (b/140855415), but the trace files within the zip should be nevertheless readable Bug: 209843622 Test: build winscope and open a zip trace Change-Id: I897ae5e1e0ea3d524c67d90318f9e63f80c6ce54 --- tools/winscope/src/DataInput.vue | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/winscope/src/DataInput.vue b/tools/winscope/src/DataInput.vue index 10427c08b..8cfa29b29 100644 --- a/tools/winscope/src/DataInput.vue +++ b/tools/winscope/src/DataInput.vue @@ -566,6 +566,14 @@ export default { return {filetype, data}; }, + /** + * Decode a zip file + * + * Load all files that can be decoded, even if some failures occur. + * For example, a zip file with an mp4 recorded via MediaProjection + * doesn't include the winscope metadata (b/140855415), but the trace + * files within the zip should be nevertheless readable + */ async decodeArchive(archive) { const buffer = await this.readFile(archive); @@ -574,6 +582,7 @@ export default { const decodedFiles = []; + let lastError; for (const filename in content.files) { if (content.files.hasOwnProperty(filename)) { const file = content.files[filename]; @@ -592,14 +601,24 @@ export default { decodedFiles.push(decodedFile); } catch (e) { if (!(e instanceof UndetectableFileType)) { - throw e; + lastError = e; } + + console.error(e); } } } if (decodedFiles.length == 0) { + if (lastError) { + throw lastError; + } throw new Error('No matching files found in archive', archive); + } else { + if (lastError) { + this.showSnackbarMessage( + 'Unable to parse all files, check log for more details', 3500); + } } return decodedFiles;