Skip to content

Commit c76b31a

Browse files
committed
refactor: remove redundant service reload and smbd check
Removed the explicit systemd Reload call after enabling services since systemd automatically handles reload when using --now option. The call was redundant and not necessary for correct operation. Also simplified the error handling in UserShareHelper by removing unnecessary smbd service check since only nmbd service is critical for the operation. The changes: 1. Removed manual systemd Reload call from SystemServiceManager::enableServiceNow 2. Simplified UserShareHelper error handling to only check nmbd service status 3. Removed redundant error message concatenation logic These changes make the code cleaner and more focused on essential operations while maintaining the same functionality. Influence: 1. Verify that services still start correctly after enabling 2. Test SMB sharing functionality to ensure it works without the explicit Reload 3. Check error messages when service enabling fails 4. Confirm nmbd service is the only critical one for share operations refactor: 移除多余的服务重载和 smbd 检查 删除了启用服务后显式调用 systemd 的 Reload 操作,因为使用 --now 选项时 systemd 会自动处理重载。该调用是多余的且对正确运行并非必要。同时简化了 UserShareHelper 的错误处理,移除了不必要的 smbd 服务检查,因为只有 nmbd 服务对该操作是关键性的。 更改内容: 1. 从 SystemServiceManager::enableServiceNow 中删除了手动 systemd Reload 调用 2. 简化 UserShareHelper 错误处理仅检查 nmbd 服务状态 3. 移除了多余的错误消息拼接逻辑 这些改动使代码更简洁,更专注于基本操作,同时保持原有功能不变。 Influence: 1. 验证启用后服务是否能正常启动 2. 测试 SMB 共享功能确保在没有显式 Reload 时仍能工作 3. 检查服务启用失败时的错误消息 4. 确认 nmbd 服务是共享操作中唯一关键的服务
1 parent 705b82f commit c76b31a

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

src/dfm-base/utils/systemservicemanager.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,6 @@ bool SystemServiceManager::enableServiceNow(const QString &serviceName)
131131

132132
if (success) {
133133
qCInfo(logDFMBase) << "SystemServiceManager: Successfully enabled service" << serviceName;
134-
// 启用服务后,systemd 会自动重载,但显式调用 Reload 以确保状态同步
135-
// 这一步也可以省略,因为 --now 已经启动了服务,enable 也已持久化
136-
QDBusInterface managerIface(
137-
kSystemdService,
138-
kSystemdManagerPath,
139-
kSystemdManagerInterface,
140-
QDBusConnection::systemBus());
141-
if (managerIface.isValid()) {
142-
managerIface.call("Reload");
143-
}
144134
} else {
145135
// pkexec 的退出码有特殊含义:
146136
// 127: 命令未找到

src/plugins/common/dfmplugin-dirshare/utils/usersharehelper.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -624,19 +624,8 @@ QPair<bool, QString> UserShareHelper::startSmbService()
624624
}
625625

626626
bool nmbdOk = SystemServiceManager::instance().enableServiceNow("nmbd.service");
627-
if (!smbdOk || !nmbdOk) {
628-
if (!smbdOk) {
629-
errMsg = "Failed to start and enable smbd.service";
630-
fmWarning() << errMsg;
631-
}
632-
if (!nmbdOk) {
633-
QString nmbdErr = "Failed to start and enable nmbd.service";
634-
fmWarning() << nmbdErr;
635-
if (!errMsg.isEmpty())
636-
errMsg += "; " + nmbdErr;
637-
else
638-
errMsg = nmbdErr;
639-
}
627+
if (!nmbdOk) {
628+
errMsg = "Failed to start and enable nmbd.service";
640629
return { false, errMsg };
641630
}
642631

0 commit comments

Comments
 (0)