Commit 67c7f43c authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Fix bug in ExtractMountNameAndFullPath to set volume root as "/"

Bug found coding/testing
https://chromium-review.googlesource.com/c/chromium/src/+/1350375

Bug: 878324
Change-Id: I800bf263f17370d43c7b8413cd6af9cd819bfd0c
Reviewed-on: https://chromium-review.googlesource.com/c/1350421Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610972}
parent 5e7d7df1
......@@ -483,10 +483,13 @@ bool ExtractMountNameAndFullPath(const base::FilePath& absolute_path,
return false;
const std::string& value = virtual_path.value();
size_t pos = value.find(base::FilePath::kSeparators[0]);
if (pos == std::string::npos)
return false;
*mount_name = value.substr(0, pos);
*full_path = value.substr(pos);
// Set full_path to '/' if |absolute_path| is a root.
if (pos == std::string::npos) {
*full_path = "/";
} else {
*full_path = value.substr(pos);
}
return true;
}
......
......@@ -392,6 +392,11 @@ TEST(FileManagerPathUtilTest, ExtractMountNameAndFullPath) {
EXPECT_EQ(mount_name, downloads_mount_name);
EXPECT_EQ(full_path, "/" + relative_path);
EXPECT_TRUE(
ExtractMountNameAndFullPath(downloads_path, &mount_name, &full_path));
EXPECT_EQ(mount_name, downloads_mount_name);
EXPECT_EQ(full_path, "/");
EXPECT_FALSE(ExtractMountNameAndFullPath(base::FilePath("/unknown/path"),
&mount_name, &full_path));
}
......
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