Fix bug in speed calculation

This commit is contained in:
Neeraj Gupta 2023-08-11 16:06:56 +05:30
parent 7773d7415b
commit 2de7bff9b7

View file

@ -41,14 +41,13 @@ Future<io.File?> 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";