chore: make sure autostart dir existed

mkdir if autostart dir not existed
This commit is contained in:
ck 2024-05-15 16:08:30 +08:00 committed by mike
parent 84db7090d5
commit 571cd93382

View File

@ -652,7 +652,14 @@ void ApplicationService::setAutoStart(bool autostart) noexcept
return;
}
auto fileName = QDir{getAutoStartDirs().first()}.filePath(m_desktopSource.desktopId() + ".desktop");
QDir startDir (getAutoStartDirs().first());
if (!startDir.exists() && !startDir.mkpath(startDir.path())) {
qWarning() << "mkpath " << startDir.path() << "failed";
safe_sendErrorReply(QDBusError::InternalError);
return;
}
auto fileName = startDir.filePath(m_desktopSource.desktopId() + ".desktop");
QFile autostartFile{fileName};
if (!autostartFile.open(QFile::WriteOnly | QFile::Text | QFile::Truncate)) {
qWarning() << "open file" << fileName << "failed:" << autostartFile.error();