From c882e9f51d1325c5624d12de58d3f6d1bf35527a Mon Sep 17 00:00:00 2001 From: wjyrich Date: Fri, 22 Aug 2025 15:12:18 +0800 Subject: [PATCH] fix: prefix desktop filename with linyaps in uninstall cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed the postUninstallCleanUp parameter to prefix the desktop filename with "linyaps-" This ensures proper cleanup when uninstalling applications by matching the expected format The previous implementation used just the filename which could cause cleanup issues fix: 在卸载清理中为桌面文件名添加 linyaps 前缀 修改 postUninstallCleanUp 参数,为桌面文件名添加 "linyaps-" 前缀 这确保了在卸载应用程序时能够正确清理,匹配预期的格式 之前的实现仅使用文件名,可能导致清理问题 Pms: BUG-317501 --- dbus/launcher1compat.cpp | 18 ++++++++++++------ dbus/launcher1compat.h | 7 +++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/dbus/launcher1compat.cpp b/dbus/launcher1compat.cpp index 3ada78a..3089100 100644 --- a/dbus/launcher1compat.cpp +++ b/dbus/launcher1compat.cpp @@ -92,15 +92,21 @@ bool uninstallLinglongBundle(const DDesktopEntry & entry) return retCode == 0; } -void postUninstallCleanUp(const QString & desktopId) +void postUninstallCleanUp(const QString & desktopId, PackageType packageType) { // Remove the shortcut that we created at user's desktop const QString &curDesktop = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); const QString &appDesktopPath = curDesktop + "/" + desktopId; - QFile file(appDesktopPath); if (file.exists()) { file.remove(); + } else if (packageType == PackageType::Linglong) { + // 只对玲珑包处理 linyaps 桌面文件 + const QString &linyapsDesktopPath = curDesktop + "/linyaps-" + desktopId; + if (QFile(linyapsDesktopPath).exists()) { + qDebug() << linyapsDesktopPath << "exists, remove it"; + QFile::remove(linyapsDesktopPath); + } } else { qDebug() << appDesktopPath << "doesn't exist, no need to remove."; } @@ -119,7 +125,7 @@ void Launcher1Compat::uninstallPackageKitPackage(const QString & pkgDisplayName, sendNotification(pkgDisplayName, true, m_base64Icon); QFileInfo fi(m_desktopFilePath); // FIXME: THIS IS NOT DESKTOP ID - postUninstallCleanUp(fi.fileName()); + postUninstallCleanUp(fi.fileName(), PackageType::Deb); }, [=](const std::exception & e){ sendNotification(pkgDisplayName, false, m_base64Icon); PKUtils::PkError::printException(e); @@ -146,7 +152,7 @@ void Launcher1Compat::uninstallDCMPackage(const QString & pkgDisplayName, const sendNotification(pkgDisplayName, true, m_base64Icon); QFileInfo fi(m_desktopFilePath); // FIXME: THIS IS NOT DESKTOP ID - postUninstallCleanUp(fi.fileName()); + postUninstallCleanUp(fi.fileName(), PackageType::DCM); } } @@ -169,7 +175,7 @@ void Launcher1Compat::uninstallPackageByScript(const QString & pkgDisplayName, c sendNotification(pkgDisplayName, true, m_base64Icon); QFileInfo fi(m_desktopFilePath); // FIXME: THIS IS NOT DESKTOP ID - postUninstallCleanUp(fi.fileName()); + postUninstallCleanUp(fi.fileName(), PackageType::Deb); } } @@ -263,7 +269,7 @@ void Launcher1Compat::RequestUninstall(const QString & desktop, bool skipPreinst // FIXME: the filename of the desktop file MIGHT NOT be its desktopId in freedesktop spec. // here is the logic from the legacy dde-application-manager which is INCORRECT in that case. QFileInfo fileInfo(desktopFilePath); - postUninstallCleanUp(fileInfo.fileName()); + postUninstallCleanUp(fileInfo.fileName(), PackageType::Linglong); emit UninstallSuccess(desktopFilePath); sendNotification(desktopEntry.ddeDisplayName(), true, m_base64Icon); } diff --git a/dbus/launcher1compat.h b/dbus/launcher1compat.h index 6605692..a1b461c 100644 --- a/dbus/launcher1compat.h +++ b/dbus/launcher1compat.h @@ -8,6 +8,13 @@ #include #include +enum class PackageType { + Linglong, // 玲珑包 + Flatpak, // Flatpak包 + Deb, // deb包/PackageKit包 + DCM // DCM兼容模式包 +}; + class Launcher1Adaptor; class Launcher1Compat : public QObject, protected QDBusContext {