diff --git a/src/shellext/scrub.cpp b/src/shellext/scrub.cpp index 52f7a9ff..57c94792 100755 --- a/src/shellext/scrub.cpp +++ b/src/shellext/scrub.cpp @@ -29,6 +29,23 @@ #include #include +static wstring format_duration(uint64_t dur, const wchar_t* fmt) { + int len = GetDurationFormatEx(LOCALE_NAME_USER_DEFAULT, 0, nullptr, dur, + fmt, nullptr, 0); + if (len == 0) + throw last_error(GetLastError()); + + wstring s; + + s.resize(len); + + if (GetDurationFormatEx(LOCALE_NAME_USER_DEFAULT, 0, nullptr, dur, + fmt, s.data(), s.size()) == 0) + throw last_error(GetLastError()); + + return s; +} + void BtrfsScrub::UpdateTextBox(HWND hwndDlg, btrfs_query_scrub* bqs) { btrfs_query_scrub* bqs2 = nullptr; bool alloc_bqs2 = false; @@ -213,7 +230,14 @@ void BtrfsScrub::UpdateTextBox(HWND hwndDlg, btrfs_query_scrub* bqs) { format_size((uint64_t)speed, d2, false); - wstring_sprintf(u, t, d1.c_str(), bqs2->duration / 10000000, d2.c_str()); + wstring dur; + + if (bqs2->duration >= 36000000000) + dur = format_duration(bqs2->duration, L"h:mm:ss"); + else + dur = format_duration(bqs2->duration, L"m:ss"); + + wstring_sprintf(u, t, d1.c_str(), dur.c_str(), d2.c_str()); s += u; s += L"\r\n"; diff --git a/src/shellext/shellbtrfs.rc.in b/src/shellext/shellbtrfs.rc.in index 118aef55..4bf5aa27 100755 --- a/src/shellext/shellbtrfs.rc.in +++ b/src/shellext/shellbtrfs.rc.in @@ -684,7 +684,7 @@ BEGIN IDS_SCRUB_MSG_UNRECOVERABLE_METADATA_FIRSTITEM "Unrecoverable metadata checksum error at %llx on device %llx (root %llx, level %x, first item %llx,%x,%llx)" IDS_SCRUB_MSG_FINISHED "Scrub finished at %s %s." - IDS_SCRUB_MSG_SUMMARY "Scrubbed %s in %llu seconds (%s/s)." + IDS_SCRUB_MSG_SUMMARY "Scrubbed %s in %s (%s/s)." IDS_BALANCE_SCRUB_RUNNING "Cannot start balance while scrub running." IDS_SCRUB_BALANCE_RUNNING "Cannot start scrub while balance running." IDS_SCRUB_MSG_SUMMARY_ERRORS_RECOVERABLE "Recovered from %llu error(s)."