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; ...@@ -18,6 +18,9 @@ constexpr int kFailedToCopyBundle = 10;
// Failed to delete the updater's install folder. // Failed to delete the updater's install folder.
constexpr int kFailedToDeleteFolder = 11; 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. // Failed to remove the active(unversioned) update service job from Launchd.
constexpr int kFailedToRemoveActiveUpdateServiceJobFromLaunchd = 20; constexpr int kFailedToRemoveActiveUpdateServiceJobFromLaunchd = 20;
......
...@@ -276,6 +276,13 @@ bool DeleteInstallFolder() { ...@@ -276,6 +276,13 @@ bool DeleteInstallFolder() {
return DeleteInstallFolder(GetUpdaterFolderPath()); return DeleteInstallFolder(GetUpdaterFolderPath());
} }
bool DeleteDataFolder() {
base::FilePath data_path;
if (!GetBaseDirectory(&data_path))
return false;
return DeleteInstallFolder(data_path);
}
} // namespace } // namespace
int InstallCandidate() { int InstallCandidate() {
...@@ -335,6 +342,9 @@ int Uninstall(bool is_machine) { ...@@ -335,6 +342,9 @@ int Uninstall(bool is_machine) {
if (!RemoveUpdateServiceJobFromLaunchd()) if (!RemoveUpdateServiceJobFromLaunchd())
return setup_exit_codes::kFailedToRemoveActiveUpdateServiceJobFromLaunchd; return setup_exit_codes::kFailedToRemoveActiveUpdateServiceJobFromLaunchd;
if (!DeleteDataFolder())
return setup_exit_codes::kFailedToDeleteDataFolder;
if (!DeleteInstallFolder()) if (!DeleteInstallFolder())
return setup_exit_codes::kFailedToDeleteFolder; return setup_exit_codes::kFailedToDeleteFolder;
......
...@@ -38,6 +38,13 @@ base::FilePath GetProductPath() { ...@@ -38,6 +38,13 @@ base::FilePath GetProductPath() {
.AppendASCII(PRODUCT_FULLNAME_STRING); .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) { bool Run(base::CommandLine command_line, int* exit_code) {
auto process = base::LaunchProcess(command_line, {}); auto process = base::LaunchProcess(command_line, {});
if (!process.IsValid()) if (!process.IsValid())
...@@ -58,6 +65,7 @@ void Clean() { ...@@ -58,6 +65,7 @@ void Clean() {
Launchd::User, Launchd::Agent, updater::CopyControlLaunchdName())); Launchd::User, Launchd::Agent, updater::CopyControlLaunchdName()));
EXPECT_TRUE(Launchd::GetInstance()->DeletePlist( EXPECT_TRUE(Launchd::GetInstance()->DeletePlist(
Launchd::User, Launchd::Agent, updater::CopyServiceLaunchdName())); Launchd::User, Launchd::Agent, updater::CopyServiceLaunchdName()));
EXPECT_TRUE(base::DeletePathRecursively(GetDataDirPath()));
} }
void ExpectClean() { void ExpectClean() {
...@@ -69,6 +77,7 @@ void ExpectClean() { ...@@ -69,6 +77,7 @@ void ExpectClean() {
Launchd::User, Launchd::Agent, updater::CopyControlLaunchdName())); Launchd::User, Launchd::Agent, updater::CopyControlLaunchdName()));
EXPECT_FALSE(Launchd::GetInstance()->PlistExists( EXPECT_FALSE(Launchd::GetInstance()->PlistExists(
Launchd::User, Launchd::Agent, updater::CopyServiceLaunchdName())); Launchd::User, Launchd::Agent, updater::CopyServiceLaunchdName()));
EXPECT_FALSE(base::PathExists(GetDataDirPath()));
} }
void ExpectInstalled() { void ExpectInstalled() {
......
...@@ -60,6 +60,14 @@ base::FilePath GetExecutablePath() { ...@@ -60,6 +60,14 @@ base::FilePath GetExecutablePath() {
return GetProductPath().AppendASCII("updater.exe"); 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 } // namespace
void Clean() { void Clean() {
...@@ -69,6 +77,7 @@ void Clean() { ...@@ -69,6 +77,7 @@ void Clean() {
// TODO(crbug.com/1062288): Delete the COM interfaces. // TODO(crbug.com/1062288): Delete the COM interfaces.
// TODO(crbug.com/1062288): Delete the Wake task. // TODO(crbug.com/1062288): Delete the Wake task.
EXPECT_TRUE(base::DeletePathRecursively(GetProductPath())); EXPECT_TRUE(base::DeletePathRecursively(GetProductPath()));
EXPECT_TRUE(base::DeletePathRecursively(GetDataDirPath()));
} }
void ExpectClean() { void ExpectClean() {
...@@ -80,8 +89,8 @@ void ExpectClean() { ...@@ -80,8 +89,8 @@ void ExpectClean() {
// TODO(crbug.com/1062288): Assert there are no Wake tasks. // TODO(crbug.com/1062288): Assert there are no Wake tasks.
// Files must not exist on the file system. // Files must not exist on the file system.
EXPECT_FALSE(base::PathExists(GetProductPath())); EXPECT_FALSE(base::PathExists(GetProductPath()));
EXPECT_FALSE(base::PathExists(GetDataDirPath()));
} }
void ExpectInstalled() { 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 \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 path. Sleeps 3 seconds and tries 3 times to delete the
rem directory. rem directory.
@echo off @echo off
set Directory=%~dp0 set Directory=%~dp0
FOR %%a IN ("%Directory:~0,-1%") DO set Directory=%%~dpa
@echo %Directory% | FindStr /R \\AppData\\Local\\@COMPANY_SHORTNAME@\\@PRODUCT_FULLNAME@\\ > nul @echo %Directory% | FindStr /R \\AppData\\Local\\@COMPANY_SHORTNAME@\\@PRODUCT_FULLNAME@\\ > nul
IF %ERRORLEVEL% NEQ 0 exit 1 IF %ERRORLEVEL% NEQ 0 exit 1
@echo Deleting "%Directory%"... @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