Product dropped Harness-home cleanup from the uninstaller, so the opt-in page, its bilingual dialog, the uninstall.ini home record and the overlap check go away. The uninstaller now always removes the Electron user-data directory, the %APPDATA% product directory and the updater cache through the native helper; the Harness home is never touched. Silent uninstalls remove the same data, upgrades retain it, and a locked file is logged instead of stopping the uninstall. Electron derives user data from the scoped package name, so the removal targets %APPDATA%\@deepseek-ai\dsh-desktop and removes the empty scope directory afterwards. The previous fixture used an unscoped name and never reached that directory; the fixture now uses a scoped package name. The native uninstall smoke runs end to end on the development host after two test fixes: the interactive uninstaller was launched hidden, which made every control invisible to the text search, and the Chinese finish text matched "已经从" instead of MUI's "已从你". The native remover regression is renamed data-cleanup-test.exe because UAC installer detection demanded elevation from the unmanifested uninstall-data-test.exe.
51 lines
2.6 KiB
C++
51 lines
2.6 KiB
C++
// Native cleanup regressions operate only in the caller's private test directory.
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#define NOMINMAX
|
|
#define UNICODE
|
|
#include <windows.h>
|
|
#include <cassert>
|
|
#include "../installer/uninstall-data.h"
|
|
|
|
static void File(const std::wstring& path) {
|
|
HANDLE file = CreateFileW(path.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
|
|
assert(file != INVALID_HANDLE_VALUE);
|
|
DWORD count;
|
|
assert(WriteFile(file, "retained", 8, &count, nullptr));
|
|
CloseHandle(file);
|
|
}
|
|
|
|
int wmain(int argc, wchar_t** argv) {
|
|
assert(argc == 2);
|
|
const std::wstring root = argv[1];
|
|
const std::wstring installation = root + L"\\application";
|
|
const std::wstring data = root + L"\\data";
|
|
assert(CreateDirectoryW(root.c_str(), nullptr));
|
|
assert(CreateDirectoryW(installation.c_str(), nullptr));
|
|
assert(CreateDirectoryW(data.c_str(), nullptr));
|
|
assert(CreateDirectoryW((data + L"\\Local Storage").c_str(), nullptr));
|
|
const std::wstring cache = data + L"\\Local Storage\\leveldb";
|
|
assert(CreateDirectoryW(cache.c_str(), nullptr));
|
|
File(data + L"\\Local State");
|
|
File(cache + L"\\CURRENT");
|
|
assert(uninstall_data::Remove(root.c_str(), installation.c_str()) == ERROR_ACCESS_DENIED);
|
|
assert(uninstall_data::Remove(L"C:\\", installation.c_str()) == ERROR_INVALID_NAME);
|
|
assert(uninstall_data::Remove(L"relative", installation.c_str()) == ERROR_INVALID_NAME);
|
|
assert(uninstall_data::Remove(L"C:\\bad*", installation.c_str()) == ERROR_INVALID_NAME);
|
|
PWSTR profile = nullptr;
|
|
assert(SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Profile, 0, nullptr, &profile)));
|
|
assert(uninstall_data::Remove(profile, installation.c_str()) == ERROR_ACCESS_DENIED);
|
|
CoTaskMemFree(profile);
|
|
HANDLE held = CreateFileW((cache + L"\\CURRENT").c_str(), GENERIC_READ, FILE_SHARE_READ,
|
|
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
|
assert(held != INVALID_HANDLE_VALUE);
|
|
assert(uninstall_data::Remove(cache.c_str(), installation.c_str()) == ERROR_SHARING_VIOLATION);
|
|
CloseHandle(held);
|
|
assert(uninstall_data::Remove(cache.c_str(), installation.c_str()) == ERROR_SUCCESS);
|
|
assert(GetFileAttributesW((data + L"\\Local State").c_str()) != INVALID_FILE_ATTRIBUTES);
|
|
assert(uninstall_data::Remove(cache.c_str(), installation.c_str()) == ERROR_SUCCESS);
|
|
assert(uninstall_data::Remove(data.c_str(), installation.c_str()) == ERROR_SUCCESS);
|
|
assert(GetFileAttributesW(data.c_str()) == INVALID_FILE_ATTRIBUTES);
|
|
assert(RemoveDirectoryW(installation.c_str()));
|
|
assert(RemoveDirectoryW(root.c_str()));
|
|
}
|