Skip to content
Merged
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
12 changes: 9 additions & 3 deletions dconfig-center/dde-dconfig-daemon/dconfig_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ inline ConfigureId getMetaConfigureId(const QString &path)
ConfigureId info;
// /usr/share/dsg/configs/[$appid]/[$subpath]/$resource.json
// Use negative lookahead (?!overrides/) to exclude override paths which should be handled by getOverrideConfigureId
static QRegularExpression usrReg(R"(/configs/(?!overrides/)(?<appid>([a-z0-9\s\-_\@\-\^!#$%&.]+\/)?)(?<subpath>([a-z0-9\s\-_\@\-\^!#$%&.]+\/)*)(?<resource>[a-z0-9\s\-_\@\-\^!#$%&.]+).json$)");
static QRegularExpression usrReg(
R"(/configs/(?!overrides/)(?<appid>(?>[a-zA-Z0-9\s_@^!#$%&.\-]+)\/)?(?<subpath>(?:(?>[a-zA-Z0-9\s_@^!#$%&.\-]+)\/)*)(?<resource>[a-zA-Z0-9\s_@^!#$%&.\-]+)\.json$)"
);

QRegularExpressionMatch match;
match = usrReg.match(path);
Expand All @@ -114,10 +116,14 @@ inline ConfigureId getOverrideConfigureId(const QString &path)
{
ConfigureId info;
// /usr/share/dsg/configs/overrides/[$appid]/$resource/[$subpath]/$override_id.json
static QRegularExpression usrReg(R"(/configs/overrides/(?<appid>([a-z0-9\s\-_\@\-\^!#$%&.]+\/)?)(?<resource>[a-z0-9\s\-_\@\-\^!#$%&.]+)/(?<subpath>([a-z0-9\s\-_\@\-\^!#$%&.]+\/)*)(?<configurationid>[a-z0-9\s\-_\@\-\^!#$%&.]+).json$)");
static QRegularExpression usrReg(
R"(/configs/overrides/(?<appid>(?>[a-zA-Z0-9\s_@^!#$%&.\-]+)\/)?(?<resource>(?>[a-zA-Z0-9\s_@^!#$%&.\-]+))/(?<subpath>(?:(?>[a-zA-Z0-9\s_@^!#$%&.\-]+)\/)*)(?<configurationid>[a-zA-Z0-9\s_@^!#$%&.\-]+)\.json$)"
);

// /etc/dsg/configs/overrides/[$appid]/$resource/[$subpath]/$override_id.json
static QRegularExpression etcReg(R"(^/etc/dsg/configs/overrides/(?<appid>([a-z0-9\s\-_\@\-\^!#$%&.]+\/)?)(?<resource>[a-z0-9\s\-_\@\-\^!#$%&.]+)/(?<subpath>([a-z0-9\s\-_\@\-\^!#$%&.]+\/)*)(?<configurationid>[a-z0-9\s\-_\@\-\^!#$%&.]+).json$)");
static QRegularExpression etcReg(
R"(^/etc/dsg/configs/overrides/(?<appid>(?>[a-zA-Z0-9\s_@^!#$%&.\-]+)\/)?(?<resource>(?>[a-zA-Z0-9\s_@^!#$%&.\-]+))/(?<subpath>(?:(?>[a-zA-Z0-9\s_@^!#$%&.\-]+)\/)*)(?<configurationid>[a-zA-Z0-9\s_@^!#$%&.\-]+)\.json$)"
);

QRegularExpressionMatch match;
match = usrReg.match(path);
Expand Down
43 changes: 28 additions & 15 deletions dconfig-center/dde-dconfig-daemon/dconfigserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ bool DSGConfigServer::isConfigurePath(const QString &path, const QString &appId)
当描述文件被修改或override目录新增、移除、修改文件时,需要重新解析对应的文件内容,
提供刷新服务,由配置工具调用来运行时刷新提供的文件访问信息。
*/
void DSGConfigServer::update(const QString &path)
std::optional<QString> DSGConfigServer::updateInternal(const QString &path)
{
qCInfo(cfLog()) << "Update resource:" << path;

Expand All @@ -445,27 +445,29 @@ void DSGConfigServer::update(const QString &path)
qPrintable(configureInfo.subpath),
qPrintable(configureInfo.resource));
if (configureInfo.isInValid()) {
QString errorMsg = QString("It's illegal resource [%1].").arg(path);
if (calledFromDBus()) {
sendErrorReply(QDBusError::Failed, errorMsg);
}
qWarning() << errorMsg;
return;
return QString("It's illegal resource [%1].").arg(path);
}


const GenericResourceKey resourceKey = getGenericResourceKey(configureInfo.resource, configureInfo.subpath);
if (auto resource = resourceObject(resourceKey)) {
qCInfo(cfLog, "Updated the resouce:[%s], for the appid:[%s].",
qPrintable(resourceKey),
qPrintable(configureInfo.appid));
const auto &innerAppid = outerAppidToInner(configureInfo.appid);
if (!resource->reparse(innerAppid)) {
QString errorMsg = QString("Update the resource path[%1] error.").arg(path);
if (calledFromDBus()) {
sendErrorReply(QDBusError::Failed, errorMsg);
}
qWarning() << qPrintable(errorMsg);
return QString("Update the resource path[%1] error.").arg(path);
}
}
return std::nullopt;
}

void DSGConfigServer::update(const QString &path)
{
const auto errorMsg = updateInternal(path);
if (errorMsg) {
qWarning() << *errorMsg;
if (calledFromDBus()) {
sendErrorReply(QDBusError::Failed, *errorMsg);
}
}
}
Expand Down Expand Up @@ -557,12 +559,23 @@ void DSGConfigServer::reload()

changedFiles.removeDuplicates();

if (changedFiles.isEmpty()) {
qCInfo(cfLog()) << "Reload completed, no files changed";
return;
}

// Process changed files
int failedCount = 0;
for (const auto &file : std::as_const(changedFiles)) {
update(file);
const auto errorMsg = updateInternal(file);
if (errorMsg) {
qCWarning(cfLog()) << "Reload failed to update file:" << file << ", reason:" << *errorMsg;
++failedCount;
}
}

qCInfo(cfLog()) << "Reload completed, processed" << changedFiles.size() << "files";
qCInfo(cfLog()) << "Reload completed, processed" << changedFiles.size() << "files,"
<< failedCount << "failed";
}

// Get all configuration file signatures
Expand Down
4 changes: 4 additions & 0 deletions dconfig-center/dde-dconfig-daemon/dconfigserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#pragma once

#include "dconfig_global.h"
#include <optional>

Check warning on line 8 in dconfig-center/dde-dconfig-daemon/dconfigserver.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <optional> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 8 in dconfig-center/dde-dconfig-daemon/dconfigserver.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <optional> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QObject>

Check warning on line 9 in dconfig-center/dde-dconfig-daemon/dconfigserver.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 9 in dconfig-center/dde-dconfig-daemon/dconfigserver.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusObjectPath>

Check warning on line 10 in dconfig-center/dde-dconfig-daemon/dconfigserver.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDBusObjectPath> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 10 in dconfig-center/dde-dconfig-daemon/dconfigserver.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusObjectPath> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusContext>

Check warning on line 11 in dconfig-center/dde-dconfig-daemon/dconfigserver.h

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDBusContext> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in dconfig-center/dde-dconfig-daemon/dconfigserver.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusContext> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusServiceWatcher>

class DSGConfigResource;
Expand Down Expand Up @@ -83,6 +84,9 @@
ConfigureId getConfigureIdByPath(const QString &path);

bool isConfigurePath(const QString &path, const QString& appId) const;

std::optional<QString> updateInternal(const QString &path);

// Reload interface related structures and methods
struct FileSignature {
qint64 size;
Expand Down
Loading