mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-17 08:16:32 +00:00
Fix effective flashing speed calculation for compressed images
Changelog-entry: Fix effective flashing speed calculation for compressed images Change-type: patch
This commit is contained in:
parent
2f08142f5a
commit
409b78fc21
@ -17,7 +17,6 @@
|
|||||||
import CircleSvg from '@fortawesome/fontawesome-free/svgs/solid/circle.svg';
|
import CircleSvg from '@fortawesome/fontawesome-free/svgs/solid/circle.svg';
|
||||||
import CheckCircleSvg from '@fortawesome/fontawesome-free/svgs/solid/check-circle.svg';
|
import CheckCircleSvg from '@fortawesome/fontawesome-free/svgs/solid/check-circle.svg';
|
||||||
import TimesCircleSvg from '@fortawesome/fontawesome-free/svgs/solid/times-circle.svg';
|
import TimesCircleSvg from '@fortawesome/fontawesome-free/svgs/solid/times-circle.svg';
|
||||||
import * as _ from 'lodash';
|
|
||||||
import outdent from 'outdent';
|
import outdent from 'outdent';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Flex, FlexProps, Link, TableColumn, Txt } from 'rendition';
|
import { Flex, FlexProps, Link, TableColumn, Txt } from 'rendition';
|
||||||
@ -104,6 +103,19 @@ const columns: Array<TableColumn<FlashError>> = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function getEffectiveSpeed(results: {
|
||||||
|
sourceMetadata: {
|
||||||
|
size: number;
|
||||||
|
blockmappedSize?: number;
|
||||||
|
};
|
||||||
|
averageFlashingSpeed: number;
|
||||||
|
}) {
|
||||||
|
const flashedSize =
|
||||||
|
results.sourceMetadata.blockmappedSize ?? results.sourceMetadata.size;
|
||||||
|
const timeSpent = flashedSize / results.averageFlashingSpeed;
|
||||||
|
return results.sourceMetadata.size / timeSpent;
|
||||||
|
}
|
||||||
|
|
||||||
export function FlashResults({
|
export function FlashResults({
|
||||||
goToMain,
|
goToMain,
|
||||||
image = '',
|
image = '',
|
||||||
@ -117,10 +129,9 @@ export function FlashResults({
|
|||||||
errors: FlashError[];
|
errors: FlashError[];
|
||||||
skip: boolean;
|
skip: boolean;
|
||||||
results: {
|
results: {
|
||||||
bytesWritten: number;
|
|
||||||
sourceMetadata: {
|
sourceMetadata: {
|
||||||
size: number;
|
size: number;
|
||||||
blockmappedSize: number;
|
blockmappedSize?: number;
|
||||||
};
|
};
|
||||||
averageFlashingSpeed: number;
|
averageFlashingSpeed: number;
|
||||||
devices: { failed: number; successful: number };
|
devices: { failed: number; successful: number };
|
||||||
@ -129,11 +140,7 @@ export function FlashResults({
|
|||||||
const [showErrorsInfo, setShowErrorsInfo] = React.useState(false);
|
const [showErrorsInfo, setShowErrorsInfo] = React.useState(false);
|
||||||
const allFailed = !skip && results.devices.successful === 0;
|
const allFailed = !skip && results.devices.successful === 0;
|
||||||
const someFailed = results.devices.failed !== 0 || errors.length !== 0;
|
const someFailed = results.devices.failed !== 0 || errors.length !== 0;
|
||||||
const effectiveSpeed = _.round(
|
const effectiveSpeed = bytesToMegabytes(getEffectiveSpeed(results)).toFixed(
|
||||||
bytesToMegabytes(
|
|
||||||
results.sourceMetadata.size /
|
|
||||||
(results.sourceMetadata.blockmappedSize / results.averageFlashingSpeed),
|
|
||||||
),
|
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user