Sfoglia il codice sorgente

Assign taskname for computer tasks

Neeraj Gupta 2 anni fa
parent
commit
b5fe6ede26
2 ha cambiato i file con 28 aggiunte e 7 eliminazioni
  1. 7 2
      lib/services/local/local_sync_util.dart
  2. 21 5
      lib/utils/crypto_util.dart

+ 7 - 2
lib/services/local/local_sync_util.dart

@@ -39,6 +39,8 @@ Future<Tuple2<List<LocalPathAsset>, List<File>>> getLocalPathAssetsAndFiles(
         "alreadySeenLocalIDs": alreadySeenLocalIDs,
         "assetList": assetsInPath,
       },
+      taskName:
+          "getLocalPathAssetsAndFiles-${pathEntity.name}-count-${assetsInPath.length}",
     );
     alreadySeenLocalIDs.addAll(result.item1);
     uniqueFiles.addAll(result.item2);
@@ -125,8 +127,11 @@ Future<LocalDiffResult> getDiffWithLocal(
   args['existingIDs'] = existingIDs;
   args['invalidIDs'] = invalidIDs;
   args['pathToLocalIDs'] = pathToLocalIDs;
-  final LocalDiffResult diffResult =
-      await computer.compute(_getLocalAssetsDiff, param: args);
+  final LocalDiffResult diffResult = await computer.compute(
+    _getLocalAssetsDiff,
+    param: args,
+    taskName: "getLocalAssetsDiff",
+  );
   if (diffResult.localPathAssets != null) {
     diffResult.uniqueLocalFiles =
         await _convertLocalAssetsToUniqueFiles(diffResult.localPathAssets!);

+ 21 - 5
lib/utils/crypto_util.dart

@@ -231,7 +231,11 @@ class CryptoUtil {
     args["cipher"] = cipher;
     args["nonce"] = nonce;
     args["key"] = key;
-    return _computer.compute(cryptoSecretboxOpenEasy, param: args);
+    return _computer.compute(
+      cryptoSecretboxOpenEasy,
+      param: args,
+      taskName: "decrypt",
+    );
   }
 
   // Decrypts the given cipher, with the given key and nonce using XSalsa20
@@ -262,7 +266,11 @@ class CryptoUtil {
     final args = <String, dynamic>{};
     args["source"] = source;
     args["key"] = key;
-    return _computer.compute(chachaEncryptData, param: args);
+    return _computer.compute(
+      chachaEncryptData,
+      param: args,
+      taskName: "encryptChaCha",
+    );
   }
 
   // Decrypts the given source, with the given key and header using XChaCha20
@@ -277,7 +285,11 @@ class CryptoUtil {
     args["source"] = source;
     args["key"] = key;
     args["header"] = header;
-    return _computer.compute(chachaDecryptData, param: args);
+    return _computer.compute(
+      chachaDecryptData,
+      param: args,
+      taskName: "decryptChaCha",
+    );
   }
 
   // Encrypts the file at sourceFilePath, with the key (if provided) and a
@@ -293,7 +305,8 @@ class CryptoUtil {
     args["sourceFilePath"] = sourceFilePath;
     args["destinationFilePath"] = destinationFilePath;
     args["key"] = key;
-    return _computer.compute(chachaEncryptFile, param: args);
+    return _computer.compute(chachaEncryptFile,
+        param: args, taskName: "encryptFile");
   }
 
   // Decrypts the file at sourceFilePath, with the given key and header using
@@ -309,7 +322,8 @@ class CryptoUtil {
     args["destinationFilePath"] = destinationFilePath;
     args["header"] = header;
     args["key"] = key;
-    return _computer.compute(chachaDecryptFile, param: args);
+    return _computer.compute(chachaDecryptFile,
+        param: args, taskName: "decryptFile");
   }
 
   // Generates and returns a 256-bit key.
@@ -407,6 +421,7 @@ class CryptoUtil {
         "memLimit": memLimit,
         "opsLimit": opsLimit,
       },
+      taskName: "deriveKey",
     );
   }
 
@@ -417,6 +432,7 @@ class CryptoUtil {
       param: {
         "sourceFilePath": source.path,
       },
+      taskName: "fileHash",
     );
   }
 }