From 82d8c3d878b54c26e62ce8186660eb4899bd362f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Boulic?= Date: Mon, 8 Aug 2022 05:16:43 +0000 Subject: [PATCH] [Files] Catch createVolumeInfo errors Bug: 1327790 Change-Id: I0c4d1a0119c9360dc0a638b86893624d7deaae1b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3809772 Reviewed-by: Luciano Pacheco Commit-Queue: Jeremie Boulic Cr-Commit-Position: refs/heads/main@{#1032427} --- .../fmpi_get_volume_root_function.cc | 3 ++- .../background/js/volume_manager_impl.js | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/chrome/browser/chromeos/extensions/file_manager/fmpi_get_volume_root_function.cc b/chrome/browser/chromeos/extensions/file_manager/fmpi_get_volume_root_function.cc index fdfce4b187455..6dde3f234e3dd 100644 --- a/chrome/browser/chromeos/extensions/file_manager/fmpi_get_volume_root_function.cc +++ b/chrome/browser/chromeos/extensions/file_manager/fmpi_get_volume_root_function.cc @@ -58,7 +58,8 @@ FileManagerPrivateInternalGetVolumeRootFunction::Run() { DCHECK(backend); file_manager::util::FileDefinition fd; if (!backend->GetVirtualPath(volume->mount_path(), &fd.virtual_path)) { - return RespondNow(Error("Volume with ID '*' not found", volume_id)); + return RespondNow( + Error("Cannot get virtual path for volume with ID '*'", volume_id)); } // Grant the caller right rights to crack URLs based on the virtual path. diff --git a/ui/file_manager/file_manager/background/js/volume_manager_impl.js b/ui/file_manager/file_manager/background/js/volume_manager_impl.js index 5c4e9d0845889..d27c9e13fbe95 100644 --- a/ui/file_manager/file_manager/background/js/volume_manager_impl.js +++ b/ui/file_manager/file_manager/background/js/volume_manager_impl.js @@ -248,15 +248,25 @@ export class VolumeManagerImpl extends EventTarget { case 'success': case VolumeManagerCommon.VolumeError.UNKNOWN_FILESYSTEM: case VolumeManagerCommon.VolumeError.UNSUPPORTED_FILESYSTEM: { + console.debug(`Mounted '${sourcePath}' as '${volumeId}'`); if (volumeMetadata.hidden) { console.debug(`Mount discarded for hidden volume: '${volumeId}'`); this.finishRequest_(requestKey, status); return; } - console.debug(`Mounted '${sourcePath}' as '${volumeId}'`); - const volumeInfo = - await volumeManagerUtil.createVolumeInfo(volumeMetadata); + let volumeInfo; + try { + volumeInfo = + await volumeManagerUtil.createVolumeInfo(volumeMetadata); + } catch (error) { + console.warn( + 'Unable to create volumeInfo for ' + + `${volumeId} mounted on ${sourcePath}.` + + `Mount status: ${status}. Error: ${error.stack || error}.`); + this.finishRequest_(requestKey, status); + throw (error); + } await this.addVolumeInfo_(volumeInfo); this.finishRequest_(requestKey, status, volumeInfo); return;