refactor: remove unused arch profileDir

This commit is contained in:
sithlord48 2025-03-17 22:03:56 -04:00 committed by Nick Bolton
parent b051c5ae60
commit 377272e917
12 changed files with 2 additions and 103 deletions

View file

@ -46,14 +46,6 @@ public:
*/
virtual std::string getInstalledDirectory() = 0;
//! Get user's profile directory
/*!
Returns the user's profile directory. If no profile directory is set,
this will return the user's profile according to the operating system,
which will depend on which user launched the program.
*/
virtual std::string getProfileDirectory() = 0;
//! Concatenate path components
/*!
Concatenate pathname components with a directory separator
@ -62,11 +54,4 @@ public:
system calls to tell us that.
*/
virtual std::string concatPath(const std::string &prefix, const std::string &suffix) = 0;
//@}
//! Set the user's profile directory
/*
Returns the user's profile directory.
*/
virtual void setProfileDirectory(const std::string &s) = 0;
};

View file

@ -86,25 +86,6 @@ std::string ArchFileUnix::getInstalledDirectory()
#endif
}
std::string ArchFileUnix::getProfileDirectory()
{
if (!m_profileDirectory.empty()) {
return m_profileDirectory;
} else {
const std::filesystem::path homeDir = getUserDirectory();
#if WINAPI_XWINDOWS
const auto xdgDir = std::getenv("XDG_CONFIG_HOME");
if (xdgDir != nullptr) {
return std::filesystem::path(xdgDir) / kAppName;
} else {
return homeDir / ".config" / kAppName;
}
#else
return homeDir / "Library" / kAppName;
#endif
}
}
std::string ArchFileUnix::concatPath(const std::string &prefix, const std::string &suffix)
{
std::string path;
@ -116,8 +97,3 @@ std::string ArchFileUnix::concatPath(const std::string &prefix, const std::strin
path += suffix;
return path;
}
void ArchFileUnix::setProfileDirectory(const std::string &s)
{
m_profileDirectory = s;
}

View file

@ -23,10 +23,5 @@ public:
virtual std::string getUserDirectory();
virtual std::string getSystemDirectory();
virtual std::string getInstalledDirectory();
virtual std::string getProfileDirectory();
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
virtual void setProfileDirectory(const std::string &s);
private:
std::string m_profileDirectory;
};

View file

@ -114,22 +114,6 @@ std::string ArchFileWindows::getInstalledDirectory()
return fileName;
}
std::string ArchFileWindows::getProfileDirectory()
{
std::string dir;
if (!m_profileDirectory.empty()) {
dir = m_profileDirectory;
} else {
TCHAR result[MAX_PATH];
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, result))) {
dir = result;
} else {
dir = getUserDirectory();
}
}
return dir;
}
std::string ArchFileWindows::concatPath(const std::string &prefix, const std::string &suffix)
{
std::string path;
@ -141,8 +125,3 @@ std::string ArchFileWindows::concatPath(const std::string &prefix, const std::st
path += suffix;
return path;
}
void ArchFileWindows::setProfileDirectory(const std::string &s)
{
m_profileDirectory = s;
}

View file

@ -23,10 +23,5 @@ public:
virtual std::string getUserDirectory();
virtual std::string getSystemDirectory();
virtual std::string getInstalledDirectory();
virtual std::string getProfileDirectory();
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
virtual void setProfileDirectory(const std::string &s);
private:
std::string m_profileDirectory;
};

View file

@ -175,8 +175,6 @@ void App::initApp(int argc, const char **argv)
parseArgs(argc, argv);
}
ARCH->setProfileDirectory(argsBase().m_profileDirectory);
// set log filter
if (!CLOG->setFilter(argsBase().m_logFilter)) {
LOG((

View file

@ -215,10 +215,6 @@ bool ArgParser::parseGenericArgs(int argc, const char *const *argv, int &i)
}
} else if (isArg(i, argc, argv, nullptr, "--enable-crypto")) {
argsBase().m_enableCrypto = true;
} else if (isArg(i, argc, argv, nullptr, "--profile-dir", 1)) {
argsBase().m_profileDirectory = argv[++i];
} else if (isArg(i, argc, argv, nullptr, "--plugin-dir", 1)) {
argsBase().m_pluginDirectory = argv[++i];
} else if (isArg(i, argc, argv, nullptr, "--tls-cert", 1)) {
argsBase().m_tlsCertFile = argv[++i];
} else if (isArg(i, argc, argv, nullptr, "--prevent-sleep")) {

View file

@ -74,12 +74,6 @@ public:
/// @brief Should the connections be TLS encrypted
bool m_enableCrypto = false;
/// @brief The dir to load settings from
std::string m_profileDirectory;
/// @brief The dir to load plugins from
std::string m_pluginDirectory;
/// @brief Contains the location of the TLS certificate file
std::string m_tlsCertFile;

View file

@ -130,11 +130,6 @@ bool CoreProcess::Deps::fileExists(const QString &path) const
return QFile::exists(path);
}
QString CoreProcess::Deps::getProfileRoot() const
{
return Settings::settingsPath();
}
//
// CoreProcess
//
@ -494,14 +489,6 @@ bool CoreProcess::addGenericArgs(QStringList &args, const ProcessMode processMod
args << "--enable-crypto";
}
#if defined(Q_OS_WIN)
// on windows, the profile directory changes depending on the user that
// launched the process (e.g. when launched with elevation). setting the
// profile dir on launch ensures it uses the same profile dir is used
// no matter how its relaunched.
args << "--profile-dir" << m_pDeps->getProfileRoot();
#endif
if (Settings::value(Settings::Core::PreventSleep).toBool()) {
args << "--prevent-sleep";
}

View file

@ -44,7 +44,6 @@ public:
}
virtual QString appPath(const QString &name) const;
virtual bool fileExists(const QString &path) const;
virtual QString getProfileRoot() const;
private:
QProcessProxy m_process;

View file

@ -73,14 +73,11 @@ TEST(ClientArgsParsingTests, parseClientArgs_setCommonArgs)
ON_CALL(argParser, checkUnexpectedArgs()).WillByDefault(Invoke(client_stubCheckUnexpectedArgs));
deskflow::ClientArgs clientArgs;
clientArgs.m_enableLangSync = false;
const int argc = 7;
std::array<const char *, argc> kLangCmd = {"stub", "--enable-crypto", "--profile-dir", "profileDir",
"--tls-cert", "tlsCertPath", "--prevent-sleep"};
const int argc = 5;
std::array<const char *, argc> kLangCmd = {"stub", "--enable-crypto", "--tls-cert", "tlsCertPath", "--prevent-sleep"};
argParser.parseClientArgs(clientArgs, argc, kLangCmd.data());
EXPECT_TRUE(clientArgs.m_enableCrypto);
EXPECT_EQ(clientArgs.m_profileDirectory, "profileDir");
EXPECT_EQ(clientArgs.m_tlsCertFile, "tlsCertPath");
EXPECT_TRUE(clientArgs.m_preventSleep);
}

View file

@ -51,13 +51,11 @@ public:
ON_CALL(*this, process()).WillByDefault(ReturnRef(m_process));
ON_CALL(*this, appPath(_)).WillByDefault(Return("stub app path"));
ON_CALL(*this, fileExists(_)).WillByDefault(Return(true));
ON_CALL(*this, getProfileRoot()).WillByDefault(Return("stub profile"));
}
MOCK_METHOD(proxy::QProcessProxy &, process, (), (override));
MOCK_METHOD(QString, appPath, (const QString &name), (const, override));
MOCK_METHOD(bool, fileExists, (const QString &path), (const, override));
MOCK_METHOD(QString, getProfileRoot, (), (const, override));
NiceMock<QProcessProxyMock> m_process;
};