Commit 8745b241 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Simplify volumeInfo retrieval code in unmount

In the current code, if |entry| is not null and |volumeInfo| is null,
the code will throw an exception.

Bug: 989364
Change-Id: Iae24eeabadd0d99f83fab8feb8cfbf3870723edf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1727829Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682605}
parent d5077348
...@@ -599,14 +599,18 @@ CommandHandler.COMMANDS_['unmount'] = new class extends Command { ...@@ -599,14 +599,18 @@ CommandHandler.COMMANDS_['unmount'] = new class extends Command {
const volumeInfo = const volumeInfo =
CommandUtil.getElementVolumeInfo(event.target, fileManager); CommandUtil.getElementVolumeInfo(event.target, fileManager);
const entry = CommandUtil.getCommandEntry(fileManager, event.target); const entry = CommandUtil.getCommandEntry(fileManager, event.target);
if (!volumeInfo && !entry) {
let volumeType;
if (entry && entry instanceof EntryList) {
volumeType = entry.rootType;
} else if (volumeInfo) {
volumeType = volumeInfo.volumeType;
} else {
event.canExecute = false; event.canExecute = false;
event.command.setHidden(true); event.command.setHidden(true);
return; return;
} }
const volumeType =
(entry instanceof EntryList) ? entry.rootType : volumeInfo.volumeType;
event.canExecute = event.canExecute =
(volumeType === VolumeManagerCommon.VolumeType.ARCHIVE || (volumeType === VolumeManagerCommon.VolumeType.ARCHIVE ||
volumeType === VolumeManagerCommon.VolumeType.REMOVABLE || volumeType === VolumeManagerCommon.VolumeType.REMOVABLE ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment