Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Extra isolate response check using nanoID

laurenspriema78831397444
diff --git a/mobile/lib/models/base/id.dart b/mobile/lib/models/base/id.dart
index 9f226eb90f..b8e5647a0a 100644
--- a/mobile/lib/models/base/id.dart
+++ b/mobile/lib/models/base/id.dart
@@ -7,3 +7,7 @@ const clusterIDLength = 22;
String newClusterID() {
return "cluster_${customAlphabet(enteWhiteListedAlphabet, clusterIDLength)}";
}
+
+String newIsolateTaskID(String task) {
+ return "${task}_${customAlphabet(enteWhiteListedAlphabet, clusterIDLength)}";
+}
diff --git a/mobile/lib/services/isolate_service.dart b/mobile/lib/services/isolate_service.dart
index 4c7227516e..31fdb0a8cf 100644
--- a/mobile/lib/services/isolate_service.dart
+++ b/mobile/lib/services/isolate_service.dart
@@ -5,6 +5,7 @@ import "package:dart_ui_isolate/dart_ui_isolate.dart";
import "package:flutter/foundation.dart" show kDebugMode;
import "package:logging/logging.dart";
import "package:photos/core/error-reporting/isolate_logging.dart";
+import "package:photos/models/base/id.dart";
import "package:photos/services/isolate_functions.dart";
import "package:synchronized/synchronized.dart";
@@ -67,10 +68,11 @@ abstract class SuperIsolate {
mainSendPort.send(receivePort.sendPort);
receivePort.listen((message) async {
- final functionIndex = message[0] as int;
+ final taskID = message[0] as String;
+ final functionIndex = message[1] as int;
final function = IsolateOperation.values[functionIndex];
- final args = message[1] as Map<String, dynamic>;
- final sendPort = message[2] as SendPort;
+ final args = message[2] as Map<String, dynamic>;
+ final sendPort = message[3] as SendPort;
late final Object data;
try {
@@ -82,7 +84,7 @@ abstract class SuperIsolate {
};
}
final logs = List<String>.from(isolateLogger.getLogStringsAndClear());
- sendPort.send({"data": data, "logs": logs});
+ sendPort.send({"taskID": taskID, "data": data, "logs": logs});
});
}
@@ -105,9 +107,14 @@ abstract class SuperIsolate {
final answerPort = ReceivePort();
_activeTasks++;
- _mainSendPort.send([operation.index, args, answerPort.sendPort]);
+ final taskID = newIsolateTaskID(operation.name);
+ _mainSendPort.send([taskID, operation.index, args, answerPort.sendPort]);
answerPort.listen((receivedMessage) {
+ if (receivedMessage['taskID'] != taskID) {
+ logger.severe("Received isolate message with wrong taskID");
+ return;
+ }
final logs = receivedMessage['logs'] as List<String>;
IsolateLogger.handLogStringsToMainLogger(logs);
final data = receivedMessage['data'];