Skip to content

Commit

Permalink
[Files] Catch createVolumeInfo errors
Browse files Browse the repository at this point in the history
Bug: 1327790
Change-Id: I0c4d1a0119c9360dc0a638b86893624d7deaae1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3809772
Reviewed-by: Luciano Pacheco <lucmult@chromium.org>
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1032427}
  • Loading branch information
Jérémie Boulic authored and Chromium LUCI CQ committed Aug 8, 2022
1 parent 19245df commit 82d8c3d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Expand Up @@ -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.
Expand Down
16 changes: 13 additions & 3 deletions ui/file_manager/file_manager/background/js/volume_manager_impl.js
Expand Up @@ -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;
Expand Down

0 comments on commit 82d8c3d

Please sign in to comment.