ADS: Fix Preset sync failure if directory missing

Change-Id: I23ed2a12753058b36a708c9aff64291782b73809
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Henning Gruendl
2020-03-09 15:05:13 +01:00
committed by Thomas Hartmann
parent 74eaa8f883
commit 9d4a6092d2

View File

@@ -909,7 +909,13 @@ namespace ADS
// Copy all missing workspace presets over to the local workspace folder
QDir presetsDir(d->m_workspacePresetsPath);
QDir workspaceDir(QFileInfo(d->m_settings->fileName()).path() + QLatin1String("/workspaces"));
QDir workspaceDir(QFileInfo(d->m_settings->fileName()).path() + QLatin1Char('/') + m_dirName);
// Try do create the 'workspaces' directory if it doesn't exist already
workspaceDir.mkpath(workspaceDir.absolutePath());
if (!workspaceDir.exists()) {
qCInfo(adsLog) << QString("Could not make directory '%1')").arg(workspaceDir.absolutePath());
return;
}
for (const auto &preset : presets) {
QString filename = preset;
@@ -920,7 +926,10 @@ namespace ADS
QFile file(filePath);
if (file.exists()) {
file.copy(workspaceDir.filePath(filename));
if (!file.copy(workspaceDir.filePath(filename))) {
qCInfo(adsLog) << QString("Could not copy '%1' to '%2' error: %3").arg(
filePath, workspaceDir.filePath(filename), file.errorString());
}
d->m_workspaceListDirty = true;
}
}