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

fix consistent log directory and config dir migration for linux #7665

Open
wants to merge 2 commits 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
8 changes: 6 additions & 2 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,12 @@ void Application::setupConfigFile()
oldDir.chop(1);
}

if (!QFileInfo(oldDir).isDir()) {
const QStringList filesList =
!Utility::isWindows()
? QDir(oldDir).entryList(QDir::Files).filter(QRegularExpression("^(?!.*\\.log).*$"))
: QDir(oldDir).entryList(QDir::Files);

if (filesList.isEmpty()) {
return;
}

Expand All @@ -552,7 +557,6 @@ void Application::setupConfigFile()

// Try to move the files one by one
if (QFileInfo(confDir).isDir() || QDir().mkdir(confDir)) {
const QStringList filesList = QDir(oldDir).entryList(QDir::Files);
qCInfo(lcApplication) << "Will move the individual files" << filesList;
for (const auto &name : filesList) {
if (!QFile::rename(oldDir + "/" + name, confDir + "/" + name)) {
Expand Down
4 changes: 2 additions & 2 deletions src/gui/syncrunfilelog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <QRegularExpression>

#include "syncrunfilelog.h"
#include "common/utility.h"
#include "libsync/configfile.h"
#include "filesystem.h"
#include <qfileinfo.h>

Expand All @@ -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 = ConfigFile().logDir();
if(!QDir(logpath).exists()) {
QDir().mkdir(logpath);
}
Expand Down
5 changes: 4 additions & 1 deletion src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,10 @@ void ConfigFile::setAutomaticLogDir(bool enabled)

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