From 538e4b1a5af960fc33663045637864410d43c3c1 Mon Sep 17 00:00:00 2001 From: Paravis Date: Sat, 21 Nov 2026 14:52:02 +0300 Subject: [PATCH] USB-installer: on drives under 50 GB the "do not copy Windows ESD" option is forced on and locked --- src/main.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2269179..eb02e59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,3 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -// Copyright (c) 2026 Paravis - #include "app.h" #include "disks.h" #include "util.h" @@ -296,10 +293,23 @@ void App::ShowSelected() if (selIdx < 0 || selIdx >= static_cast(disks.size())) { selIdx = 0; } + if (EsdLocked()) { + noEsd = true; + DebugLog(L"disk < 50 GB: noEsd forced"); + } CheckInstalled(); InvalidateAll(); } +bool App::EsdLocked() const +{ + if (disks.empty() || selIdx < 0 || selIdx >= static_cast(disks.size())) { + return false; + } + // 50 GB по реальной ёмкости: флешка "32 ГБ" реально ~30 ГБ, "64 ГБ" ~63.8 ГБ + return disks[selIdx].size < 50000000000ULL; +} + void App::CheckInstalled() { installed = false; @@ -507,7 +517,7 @@ void App::Paint(HDC dc) const int cbX = 16; const int cbY = 114; const int cbSize = 14; - bool checkEnabled = esdPfAvailable && !busy; + bool checkEnabled = esdPfAvailable && !busy && !EsdLocked(); COLORREF boxFill = checkEnabled ? RGB(255, 255, 255) : ColorFromHex(0xF2F3F5); COLORREF boxBorder = checkEnabled ? checkBorder : ColorFromHex(0xD5DAE3); COLORREF boxText = checkEnabled ? checkFg : ColorFromHex(0xA0A6B1); @@ -736,7 +746,7 @@ void App::OnPoll() checkDown = true; } else if (checkDown) { checkDown = false; - if (hit == Hit::Check && !leftDown && esdPfAvailable) { + if (hit == Hit::Check && !leftDown && esdPfAvailable && !EsdLocked()) { noEsd = !noEsd; DebugLog(L"checkbox noEsd=%d", noEsd ? 1 : 0); InvalidateAll();