Commit 9d1340fc authored by Joshua Pawlicki's avatar Joshua Pawlicki Committed by Commit Bot

Updater: uninstall now deletes updater data dir.

On Mac, uninstall deletes the app data dir altogether.
On Win, uninstall deletes the app's grandparent dir, which contains
the program executable, logs, and prefs file.

Bug: 1115135
Change-Id: Ife281abeafd265b1cd50f6fcb67212b49eccc5ef
Fixed: 1115135
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2353192
Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798257}
parent 0b0daea7
......@@ -18,6 +18,9 @@ constexpr int kFailedToCopyBundle = 10;
// Failed to delete the updater's install folder.
constexpr int kFailedToDeleteFolder = 11;
// Failed to delete the updater's data folder.
constexpr int kFailedToDeleteDataFolder = 12;
// Failed to remove the active(unversioned) update service job from Launchd.
constexpr int kFailedToRemoveActiveUpdateServiceJobFromLaunchd = 20;
......
......@@ -276,6 +276,13 @@ bool DeleteInstallFolder() {
return DeleteInstallFolder(GetUpdaterFolderPath());
}
bool DeleteDataFolder() {
base::FilePath data_path;
if (!GetBaseDirectory(&data_path))
return false;
return DeleteInstallFolder(data_path);
}
} // namespace
int InstallCandidate() {
......@@ -335,6 +342,9 @@ int Uninstall(bool is_machine) {
if (!RemoveUpdateServiceJobFromLaunchd())
return setup_exit_codes::kFailedToRemoveActiveUpdateServiceJobFromLaunchd;
if (!DeleteDataFolder())
return setup_exit_codes::kFailedToDeleteDataFolder;
if (!DeleteInstallFolder())
return setup_exit_codes::kFailedToDeleteFolder;
......
......@@ -38,6 +38,13 @@ base::FilePath GetProductPath() {
.AppendASCII(PRODUCT_FULLNAME_STRING);
}
base::FilePath GetDataDirPath() {
return base::mac::GetUserLibraryPath()
.AppendASCII("Application Support")
.AppendASCII(COMPANY_SHORTNAME_STRING)
.AppendASCII(PRODUCT_FULLNAME_STRING);
}
bool Run(base::CommandLine command_line, int* exit_code) {
auto process = base::LaunchProcess(command_line, {});
if (!process.IsValid())
......@@ -58,6 +65,7 @@ void Clean() {
Launchd::User, Launchd::Agent, updater::CopyControlLaunchdName()));
EXPECT_TRUE(Launchd::GetInstance()->DeletePlist(
Launchd::User, Launchd::Agent, updater::CopyServiceLaunchdName()));
EXPECT_TRUE(base::DeletePathRecursively(GetDataDirPath()));
}
void ExpectClean() {
......@@ -69,6 +77,7 @@ void ExpectClean() {
Launchd::User, Launchd::Agent, updater::CopyControlLaunchdName()));
EXPECT_FALSE(Launchd::GetInstance()->PlistExists(
Launchd::User, Launchd::Agent, updater::CopyServiceLaunchdName()));
EXPECT_FALSE(base::PathExists(GetDataDirPath()));
}
void ExpectInstalled() {
......
......@@ -60,6 +60,14 @@ base::FilePath GetExecutablePath() {
return GetProductPath().AppendASCII("updater.exe");
}
base::FilePath GetDataDirPath() {
base::FilePath app_data_dir;
if (!base::PathService::Get(base::DIR_LOCAL_APP_DATA, &app_data_dir))
return base::FilePath();
return app_data_dir.AppendASCII(COMPANY_SHORTNAME_STRING)
.AppendASCII(PRODUCT_FULLNAME_STRING);
}
} // namespace
void Clean() {
......@@ -69,6 +77,7 @@ void Clean() {
// TODO(crbug.com/1062288): Delete the COM interfaces.
// TODO(crbug.com/1062288): Delete the Wake task.
EXPECT_TRUE(base::DeletePathRecursively(GetProductPath()));
EXPECT_TRUE(base::DeletePathRecursively(GetDataDirPath()));
}
void ExpectClean() {
......@@ -80,8 +89,8 @@ void ExpectClean() {
// TODO(crbug.com/1062288): Assert there are no Wake tasks.
// Files must not exist on the file system.
EXPECT_FALSE(base::PathExists(GetProductPath()));
EXPECT_FALSE(base::PathExists(GetDataDirPath()));
}
void ExpectInstalled() {
......
rem Deletes the script's parent directory if
rem Deletes the script's grandparent directory if
rem \AppData\Local\@COMPANY_SHORTNAME@\@PRODUCT_FULLNAME@\ is anywhere in the
rem directory path. Sleeps 3 seconds and tries 3 times to delete the
rem directory.
@echo off
set Directory=%~dp0
FOR %%a IN ("%Directory:~0,-1%") DO set Directory=%%~dpa
@echo %Directory% | FindStr /R \\AppData\\Local\\@COMPANY_SHORTNAME@\\@PRODUCT_FULLNAME@\\ > nul
IF %ERRORLEVEL% NEQ 0 exit 1
@echo Deleting "%Directory%"...
......
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