Skip to content

Commit ba5daf3

Browse files
committed
Don't insert update helper desktop action if updates info is missing
1 parent c594583 commit ba5daf3

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

src/shared/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_library(shared STATIC shared.h shared.cpp)
2-
target_link_libraries(shared PUBLIC PkgConfig::glib Qt5::Core Qt5::Widgets Qt5::DBus xdg-basedir libappimage translationmanager trashbin)
2+
target_link_libraries(shared PUBLIC PkgConfig::glib Qt5::Core Qt5::Widgets Qt5::DBus xdg-basedir libappimage translationmanager trashbin libappimageupdate)
33
target_compile_definitions(shared
44
PRIVATE -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
55
PRIVATE -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"

src/shared/shared.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern "C" {
2727
#include <QRegularExpression>
2828
#include <QSettings>
2929
#include <QStandardPaths>
30+
#include <appimage/update.h>
3031

3132
// local headers
3233
#include "shared.h"
@@ -422,19 +423,23 @@ bool installDesktopFileAndIcons(const QString& pathToAppImage, bool resolveColli
422423
#ifdef ENABLE_UPDATE_HELPER
423424
// add Update action
424425
{
425-
const auto updateSectionName = "Desktop Action Update";
426-
427-
g_key_file_set_string(desktopFile.get(), updateSectionName, "Name", "Update AppImage");
428-
429-
std::ostringstream updateExecPath;
430-
updateExecPath << CMAKE_INSTALL_PREFIX << "/" << CMAKE_INSTALL_LIBDIR << "/appimagelauncher/update " << pathToAppImage.toStdString();
431-
g_key_file_set_string(desktopFile.get(), updateSectionName, "Exec", updateExecPath.str().c_str());
432-
433-
// install translations
434-
auto it = QMapIterator<QString, QString>(updateActionNameTranslations);
435-
while (it.hasNext()) {
436-
auto entry = it.next();
437-
g_key_file_set_locale_string(desktopFile.get(), updateSectionName, "Name", entry.key().toStdString().c_str(), entry.value().toStdString().c_str());
426+
appimage::update::Updater updater(pathToAppImage.toStdString());
427+
if (!updater.updateInformation().empty()) {
428+
const auto updateSectionName = "Desktop Action Update";
429+
430+
g_key_file_set_string(desktopFile.get(), updateSectionName, "Name", "Update AppImage");
431+
432+
std::ostringstream updateExecPath;
433+
updateExecPath << CMAKE_INSTALL_PREFIX << "/" << CMAKE_INSTALL_LIBDIR << "/appimagelauncher/update "
434+
<< pathToAppImage.toStdString();
435+
g_key_file_set_string(desktopFile.get(), updateSectionName, "Exec", updateExecPath.str().c_str());
436+
437+
// install translations
438+
auto it = QMapIterator<QString, QString>(updateActionNameTranslations);
439+
while (it.hasNext()) {
440+
auto entry = it.next();
441+
g_key_file_set_locale_string(desktopFile.get(), updateSectionName, "Name", entry.key().toStdString().c_str(), entry.value().toStdString().c_str());
442+
}
438443
}
439444
}
440445
#endif

0 commit comments

Comments
 (0)