Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chaning directories for logs and state files #7868

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ AccountManager::AccountsRestoreResult AccountManager::restore(const bool alsoRes
const auto jar = qobject_cast<CookieJar*>(acc->_networkAccessManager->cookieJar());
Q_ASSERT(jar);
if (jar) {
acc->tryMigrateCookieJar();
jar->restore(acc->cookieJarPath());
}
addAccountState(accState);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/syncrunfilelog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void SyncRunFileLog::start(const QString &folderPath)
{
const qint64 logfileMaxSize = 10 * 1024 * 1024; // 10MiB

const QString logpath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
const QString logpath = QStandardPaths::writableLocation(QStandardPaths::StateLocation);
if(!QDir(logpath).exists()) {
QDir().mkdir(logpath);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/updater/ocupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void OCUpdater::slotStartInstaller()
return QDir::toNativeSeparators(path);
};

QString msiLogFile = cfg.configPath() + "msi.log";
QString msiLogFile = cfg.logDir() + "msi.log";
QString command = QStringLiteral("&{msiexec /i '%1' /L*V '%2'| Out-Null ; &'%3'}")
.arg(preparePathForPowershell(updateFile))
.arg(preparePathForPowershell(msiLogFile))
Expand Down
13 changes: 12 additions & 1 deletion src/libsync/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,20 @@ void Account::lendCookieJarTo(QNetworkAccessManager *guest)
jar->setParent(oldParent); // takes it back
}

void Account::tryMigrateCookieJar()
{
QString oldCookieJarPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/cookies" + id() + ".db";
if (QFile::exists(oldCookieJarPath))
{
qDebug() << "Migrating cookie jar from "<< oldCookieJarPath << "to " << cookieJarPath();
if (!QFile::rename(oldCookieJarPath, cookieJarPath()))
qWarning() << "Failed to migrate cookie jar";
}
}

QString Account::cookieJarPath()
{
return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/cookies" + id() + ".db";
return QStandardPaths::writableLocation(QStandardPaths::StateLocation) + "/cookies" + id() + ".db";
}

void Account::resetNetworkAccessManager()
Expand Down
1 change: 1 addition & 0 deletions src/libsync/account.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject

void clearCookieJar();
void lendCookieJarTo(QNetworkAccessManager *guest);
void tryMigrateCookieJar();
QString cookieJarPath();

void resetNetworkAccessManager();
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ void ConfigFile::setAutomaticLogDir(bool enabled)

QString ConfigFile::logDir() const
{
const auto defaultLogDir = QString(configPath() + QStringLiteral("/logs"));
const auto defaultLogDir = QString(QStandardPaths::writableLocation(QStandardPaths::StateLocation) + QStringLiteral("/logs"));
QSettings settings(configFile(), QSettings::IniFormat);
return settings.value(QLatin1String(logDirC), defaultLogDir).toString();
}
Expand Down