Bladeren bron

Log download speeds

Vishnu Mohandas 4 jaren geleden
bovenliggende
commit
ec0972d7ba
1 gewijzigde bestanden met toevoegingen van 6 en 0 verwijderingen
  1. 6 0
      lib/utils/file_util.dart

+ 6 - 0
lib/utils/file_util.dart

@@ -160,6 +160,7 @@ Future<io.File> _downloadAndDecrypt(File file, BaseCacheManager cacheManager,
 
 
   final encryptedFile = io.File(encryptedFilePath);
   final encryptedFile = io.File(encryptedFilePath);
   final decryptedFile = io.File(decryptedFilePath);
   final decryptedFile = io.File(decryptedFilePath);
+  final startTime = DateTime.now().millisecondsSinceEpoch;
   return Dio()
   return Dio()
       .download(
       .download(
     file.getDownloadUrl(),
     file.getDownloadUrl(),
@@ -175,6 +176,11 @@ Future<io.File> _downloadAndDecrypt(File file, BaseCacheManager cacheManager,
       return null;
       return null;
     }
     }
     logger.info("File downloaded: " + file.uploadedFileID.toString());
     logger.info("File downloaded: " + file.uploadedFileID.toString());
+    logger.info("Download speed: " +
+        (io.File(encryptedFilePath).lengthSync() /
+                (DateTime.now().millisecondsSinceEpoch - startTime))
+            .toString() +
+        "kBps");
     await CryptoUtil.decryptFile(encryptedFilePath, decryptedFilePath,
     await CryptoUtil.decryptFile(encryptedFilePath, decryptedFilePath,
         Sodium.base642bin(file.fileDecryptionHeader), decryptFileKey(file));
         Sodium.base642bin(file.fileDecryptionHeader), decryptFileKey(file));
     logger.info("File decrypted: " + file.uploadedFileID.toString());
     logger.info("File decrypted: " + file.uploadedFileID.toString());