From dd0b9fe8ead4853839ce58fdbb6ac5b41007e942 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 15:21:48 +0000 Subject: [PATCH] Move gran to fallback path and fix adaptive ETA for NVMe drives Co-authored-by: ashaduri <2302268+ashaduri@users.noreply.github.com> --- src/applib/selftest.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/applib/selftest.cpp b/src/applib/selftest.cpp index 7cc75c5..952ecd8 100644 --- a/src/applib/selftest.cpp +++ b/src/applib/selftest.cpp @@ -89,13 +89,8 @@ std::chrono::seconds SelfTest::get_remaining_seconds() const { using namespace std::literals; - const std::chrono::seconds total = get_min_duration_seconds(); - if (total <= 0s) - return -1s; // unknown - - const double gran = (double(total.count()) / 9.); // seconds per 10% (drive estimate) - - // Use adaptive estimation if we have observed at least one completed segment + // Use adaptive estimation if we have observed at least one completed segment. + // This works for all drive types including NVMe (which may not report total duration). if (!segment_durations_.empty()) { // Calculate average duration of observed segments double sum = 0.0; @@ -117,6 +112,12 @@ std::chrono::seconds SelfTest::get_remaining_seconds() const } // Fall back to drive's initial estimate when we don't have observed data yet + const std::chrono::seconds total = get_min_duration_seconds(); + if (total <= 0s) + return -1s; // unknown + + // seconds per 10% (drive estimate) + const double gran = (double(total.count()) / 9.); // since remaining_percent_ may be manually set to 100, we limit from the above. const double rem_seconds_at_last_change = std::min(double(total.count()), gran * remaining_percent_ / 10.); const double rem = rem_seconds_at_last_change - timer_.elapsed();