Commit 6d63b5ff authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Crostini share: fix unshare to work for filesystem roots

Fixed file_manager::path_util::ConvertFileSystemURLToPathsInsideCrostini
to correctly handle filesystem roots.

Added tests for path_util, and crostini unshare.

Bug: 907256
Change-Id: I0397c45330dae0d2a88f3d1f83c0a9c3a1349337
Reviewed-on: https://chromium-review.googlesource.com/c/1345379Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609900}
parent 437f4542
......@@ -516,6 +516,16 @@ TEST_F(CrostiniSharePathTest, UnsharePathSuccess) {
run_loop()->Run();
}
TEST_F(CrostiniSharePathTest, UnsharePathRoot) {
crostini_share_path()->UnsharePath(
"vm-running", downloads_,
base::BindOnce(&CrostiniSharePathTest::UnsharePathCallback,
base::Unretained(this), downloads_,
SeneschalClientCalled::YES, "MyFiles/Downloads",
Success::YES, ""));
run_loop()->Run();
}
TEST_F(CrostiniSharePathTest, UnsharePathVmNotRunning) {
crostini_share_path()->UnsharePath(
"vm-not-running", shared_path_,
......
......@@ -227,7 +227,9 @@ bool ConvertFileSystemURLToPathInsideCrostini(
const storage::FileSystemURL& file_system_url,
base::FilePath* inside) {
const std::string& id(file_system_url.mount_filesystem_id());
base::FilePath path(file_system_url.virtual_path());
// File system root requires strip trailing separator.
base::FilePath path =
base::FilePath(file_system_url.virtual_path()).StripTrailingSeparators();
std::string mount_point_name_crostini = GetCrostiniMountPointName(profile);
std::string mount_point_name_downloads = GetDownloadsMountPointName(profile);
// Include drive if using DriveFS.
......@@ -286,7 +288,8 @@ bool ConvertFileSystemURLToPathInsideCrostini(
} else {
return false;
}
return base_to_exclude.AppendRelativePath(path, inside);
return base_to_exclude == path ||
base_to_exclude.AppendRelativePath(path, inside);
}
bool ConvertPathToArcUrl(const base::FilePath& path, GURL* arc_url_out) {
......
......@@ -295,6 +295,23 @@ TEST(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) {
EXPECT_EQ("/mnt/chromeos/MyFiles/Downloads/path/in/downloads",
inside.value());
EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini(
&profile,
mount_points->CreateExternalFileSystemURL(
GURL(), "Downloads-testing_profile-hash",
base::FilePath("path/in/downloads/")),
&inside));
EXPECT_EQ("/mnt/chromeos/MyFiles/Downloads/path/in/downloads",
inside.value());
EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini(
&profile,
mount_points->CreateExternalFileSystemURL(
GURL(), "Downloads-testing_profile-hash", base::FilePath()),
&inside));
EXPECT_EQ("/mnt/chromeos/MyFiles/Downloads", inside.value());
EXPECT_FALSE(ConvertFileSystemURLToPathInsideCrostini(
&profile,
mount_points->CreateExternalFileSystemURL(
......
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