From 2de7bff9b7714cc5bac230c2a7a69304d05a3fb1 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 11 Aug 2023 16:06:56 +0530 Subject: [PATCH] Fix bug in speed calculation --- lib/utils/file_download_util.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/utils/file_download_util.dart b/lib/utils/file_download_util.dart index fd83ea0f4..8f5ad67af 100644 --- a/lib/utils/file_download_util.dart +++ b/lib/utils/file_download_util.dart @@ -41,14 +41,13 @@ Future downloadAndDecrypt( _logger.warning('$logPrefix incomplete download, file not found'); return null; } - _logger.info('$logPrefix download completed'); + final int sizeInBytes = await encryptedFile.length(); + final double speedInKBps = sizeInBytes / + 1024.0 / + ((DateTime.now().millisecondsSinceEpoch - startTime) / 1000); _logger.info( - "$logPrefix avg speed: " + - (await io.File(encryptedFilePath).length() / - (DateTime.now().millisecondsSinceEpoch - startTime)) - .toString() + - "kBps", - ); + "$logPrefix download completed, avg speed: ${speedInKBps.toStringAsFixed(2)} KB/s",); + final decryptedFilePath = Configuration.instance.getTempDirectory() + file.generatedID.toString() + ".decrypted";