From e90521a9290923585dac76e76c90f3616bd44247 Mon Sep 17 00:00:00 2001
From: Akira Ohgaki <akiraohgaki@gmail.com>
Date: Sat, 16 Jun 2018 02:19:20 +0900
Subject: [PATCH] Fix detection of new filename in AppImage update information

---
 app/src/handlers/updatehandler.cpp | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/app/src/handlers/updatehandler.cpp b/app/src/handlers/updatehandler.cpp
index 7de49c5..90e57db 100644
--- a/app/src/handlers/updatehandler.cpp
+++ b/app/src/handlers/updatehandler.cpp
@@ -160,14 +160,28 @@ void UpdateHandler::updateAppImage(const QString &itemKey)
     metadata["installed_item_obj"] = installedItem;
     metadata["new_filename"] = filename;
 
+    QString assembledNewFilename = "";
+    QString rawNewFilename = "";
+
     auto updateInformation = updater->describeAppImage();
     for (const auto &info : updateInformation.split("\n")) {
         if (info.endsWith(".zsync", Qt::CaseInsensitive)) {
-            metadata["new_filename"] = info.split("|").last().split("/").last().replace(".zsync", "", Qt::CaseInsensitive);
-            break;
+            if (info.startsWith("Assembled ZSync URL:", Qt::CaseInsensitive)) {
+                assembledNewFilename = info.split("/").last().replace(".zsync", "", Qt::CaseInsensitive);
+            }
+            else if (info.startsWith("Raw update information:", Qt::CaseInsensitive)) {
+                rawNewFilename = info.split("|").last().split("/").last().replace(".zsync", "", Qt::CaseInsensitive);
+            }
         }
     }
 
+    if (!assembledNewFilename.isEmpty()) {
+        metadata["new_filename"] = assembledNewFilename;
+    }
+    else if (!rawNewFilename.isEmpty() && !rawNewFilename.contains("*")) {
+        metadata["new_filename"] = rawNewFilename;
+    }
+
     metadataSet_[itemKey] = metadata;
 
     emit updateStarted(itemKey, true);
-- 
GitLab