From 69be23c5f629884465dec98efcb9d5a2678b4df5 Mon Sep 17 00:00:00 2001
From: Petr Mrázek <peterix@gmail.com>
Date: Fri, 18 Nov 2016 16:04:08 +0100
Subject: GH-1726 better failure detection for updates

Instead of just checking if the new version started, make sure
it is able to write its IPC key to a file and then use the key
to connect to the process.
---
 api/logic/updater/DownloadTask_test.cpp |  4 ++--
 api/logic/updater/GoUpdate.h            | 21 ++++++++++++---------
 2 files changed, 14 insertions(+), 11 deletions(-)

(limited to 'api/logic')

diff --git a/api/logic/updater/DownloadTask_test.cpp b/api/logic/updater/DownloadTask_test.cpp
index 5b88b366..e75c3ffa 100644
--- a/api/logic/updater/DownloadTask_test.cpp
+++ b/api/logic/updater/DownloadTask_test.cpp
@@ -52,8 +52,8 @@ QDebug operator<<(QDebug dbg, const Operation::Type &t)
 
 QDebug operator<<(QDebug dbg, const Operation &u)
 {
-	dbg.nospace() << "Operation(type=" << u.type << " file=" << u.file
-				  << " dest=" << u.dest << " mode=" << u.mode << ")";
+	dbg.nospace() << "Operation(type=" << u.type << " file=" << u.source
+				  << " dest=" << u.destination << " mode=" << u.destinationMode << ")";
 	return dbg.maybeSpace();
 }
 
diff --git a/api/logic/updater/GoUpdate.h b/api/logic/updater/GoUpdate.h
index b8a534de..95f26b8c 100644
--- a/api/logic/updater/GoUpdate.h
+++ b/api/logic/updater/GoUpdate.h
@@ -68,19 +68,22 @@ typedef QList<VersionFileEntry> VersionFileList;
  */
 struct MULTIMC_LOGIC_EXPORT Operation
 {
-	static Operation CopyOp(QString fsource, QString fdest, int fmode=0644)
+	static Operation CopyOp(QString from, QString to, int fmode=0644)
 	{
-		return Operation{OP_REPLACE, fsource, fdest, fmode};
+		return Operation{OP_REPLACE, from, to, fmode};
 	}
 	static Operation DeleteOp(QString file)
 	{
-		return Operation{OP_DELETE, file, "", 0644};
+		return Operation{OP_DELETE, QString(), file, 0644};
 	}
 
 	// FIXME: for some types, some of the other fields are irrelevant!
 	bool operator==(const Operation &u2) const
 	{
-		return type == u2.type && file == u2.file && dest == u2.dest && mode == u2.mode;
+		return type == u2.type &&
+			source == u2.source &&
+			destination == u2.destination &&
+			destinationMode == u2.destinationMode;
 	}
 
 	//! Specifies the type of operation that this is.
@@ -90,14 +93,14 @@ struct MULTIMC_LOGIC_EXPORT Operation
 		OP_DELETE,
 	} type;
 
-	//! The file to operate on.
-	QString file;
+	//! The source file, if any
+	QString source;
 
 	//! The destination file.
-	QString dest;
+	QString destination;
 
-	//! The mode to change the source file to.
-	int mode;
+	//! The mode to change the destination file to.
+	int destinationMode;
 };
 typedef QList<Operation> OperationList;
 
-- 
cgit