Capture-MclCache: read files MCL still has open, skip any it cannot

This commit is contained in:
cproudlock
2026-10-18 09:21:28 -04:00
parent 3b3041173b
commit 902ce5780a
2 changed files with 100 additions and 4 deletions

View File

@@ -12,9 +12,11 @@ its own log (`AppVersion: 4.0.0.20`). Everything in this document was verified
against a 4.0.0.20 run on bay 579C144 that day: the media drive resolved to `Z:\`,
`W:` was created by `PrepareDisk` and used for every copy destination, the fallback
unattend at `Deploy\FlatUnattendW10.xml` was the one loaded, and driver selection
matched `win11_optiplexd13mlk7020_a09.zip` by model. The decompiled detail below has
not been re-derived from the 4.0.0.20 binary, so treat exact line-level claims as
4.0.0.17 and the observed behaviour as current.
matched `win11_optiplexd13mlk7020_a09.zip` by model. Most of the decompiled detail
below has not been re-derived from the 4.0.0.20 binary, so treat exact line-level
claims as 4.0.0.17 and the observed behaviour as current. The exception is
"The Patch Tuesday freshness gate" under GATHER DATA, which was decompiled from
4.0.0.20 on 2026-08-21 and does NOT exist in 4.0.0.17.
## How to re-derive this
@@ -110,6 +112,74 @@ Four operations, all automatic:
6. Otherwise `GetDriverByModel` (below).
7. If `Control\skip.json` exists, package installation is skipped.
### The Patch Tuesday freshness gate (4.0.0.20, NOT in 4.0.0.17)
Added after this document was first written, and it is the last thing
`GatherDataSelection` does before it succeeds. Verified against the 4.0.0.20
binary on 2026-08-21.
```csharp
DateTime lastPatchTuesday = MiscHelpers.GetLastPatchTuesday();
DateTime dateTime = lastPatchTuesday.AddDays(10.0);
if (!(DateTime.Now > lastPatchTuesday) || !(DateTime.Now < dateTime))
{
bool flag = true;
if (!string.IsNullOrEmpty(osv.operatingSystemVersion.wim.creationDate)) {
DateTime d2 = DateTime.ParseExact(..., "yyyy-MM-dd", ...);
if (d2 > lastPatchTuesday) flag = false;
}
if (imageinfo.LastUpdate >= dateTime) flag = false;
if (flag) {
SetResult(Failed, "gatherdata_mediadrive_error_patchday");
imageinfo.IsUpdateRequired = true;
}
}
```
`GetLastPatchTuesday` returns the second Tuesday of this month, or of the
previous month when today is on or before it. That makes `DateTime.Now >
lastPatchTuesday` always true, so only the `DateTime.Now >= lastPatchTuesday +
10 days` half of the guard ever fires. In effect: **from Patch Tuesday + 10
onward, the media must prove it is at least that fresh, or imaging fails.**
Two things can satisfy it. Neither is a package check; both are dates.
1. `Control\OperatingSystem.json` -> `wim.creationDate`, format `yyyy-MM-dd`,
later than the last Patch Tuesday. Our OperatingSystem.json has no
`creationDate` field at all, so this branch never runs here.
2. `imageinfo.LastUpdate`, which is nothing more than the mtime of
`<media>\Deploy\Control\Media.tag` (set in `GatherDataMediaDrive.
CheckLastWriteTime`, the same read that drives the 30-day expiry).
So on this server the gate reduces to one question: is Media.tag's mtime on or
after the last Patch Tuesday + 10 days?
**The midnight trap.** `/etc/cron.d/media-tag-refresh` touches Media.tag at
00:00:01 server local time. WinPE renders SMB file times about an hour behind
the server, which drops a 00:00 stamp back onto the previous day. That is
invisible for 29 days a month and fatal on exactly one: the Patch Tuesday + 10
boundary day, when the gate compares against midnight of that very date. Hit on
2026-08-21 (PESetup log showed `Last Imaging Source Update: '2026-08-20'`
against `Last Patch Tuesday + 10 days: '2026-08-21'`), on a Dell Pro Tower Plus
QBT1250 that was otherwise fine: driver matched, secure boot on, media view
intact. It recurs every month on Patch Tuesday + 10.
Restamp Media.tag at a mid-day hour, never at midnight. It must also stay in the
PAST relative to the bay clock: a future mtime makes `CheckLastWriteTime` set
`isBiosTimeCorrect = false` and fail with the BIOS-time error instead.
The failure text itself is useless. `gatherdata_mediadrive_error_patchday`
renders as an empty `####ERROR:` line in the log, so the three INFO lines above
it are the only diagnosis:
```
Last Imaging Source Update: '<Media.tag mtime>'
Last Patch Tuesday: '<second Tuesday>'
Last Patch Tuesday + 10 days: '<deadline>'
Imaging Source Update required: True
```
### 2. SELECT OS
Operator-facing. Warns when the media holds an LTSC image ("99% of the time only