You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[release/3.1] Single file: Guard against partial cleanup of extracted files
** Issue
dotnet/runtime#3778
** Customer Scenario
Single-file apps rely on extractiong their contents to disk.
The extaction is performed to a temp-directory by default, which may be cleaned up by the OS.
The app can re-extract itself if the entire extraction is cleaned up -- but not partial deletions.
Customers have noticed that for some apps, the extracted files were removed, but the extraction directory itself wasn't.
This causes the app to fail to start.
** Problem
When executing single-file apps, if a pre-existing extraction exists, it is assumed to be valid.
** Solution
When executing single-file apps, if a pre-existing extraction exists, the contents of the extraction directory are now verified.
If files are missing, they are recovered.
**Extraction Algorithm**
`ExtractionDir` = `$DOTNET_BUNDLE_EXTRACT_BASE_DIR/<app>/<bundle-id>`
`WorkingDir` = `$DOTNET_BUNDLE_EXTRACT_BASE_DIR/<app>/<process-id>`
If `ExtractionDir` does not exist, then
Create `WorkingDir`, and extract bundle contents within it
Attempt to rename `WorkingDir` as `ExtractionDir`
If the rename succeeds, continue execution of the app
If not, another process completed extraction; Verify and reuse this extraction (as in step 2).
If `ExtractionDir` exists, then verify that it contains all files listed in the manifest.
If all contents are available,
Remove `WorkingDir`
Continue execution of the app, reusing the contents.
If certain files are missing within `ExtractionDir`, then
For each missing file, do the following individually
Extract the files within `WorkingDir`
Create sub-paths within `ExtractionDir` if necessary
Rename the file from `WorkingDir/path/<file>` to `ExtractionDir/path/<file>` unless `ExtractionDir/path/<file>` exists (extracted there by another process in the meantime)
Remove `WorkingDir`
Continue execution of the app.
All of the renames above are done with appropriate retries to circumvent interference from anti-virus apps.
** Startup time impact
* Console HelloWorld execution time:
* Framework dependent app: Windows/Linux No measurable difference
* Self-contained app: Windows: ~10ms additional
* Self-contained app: Linux: No measurable difference
* Greenshot Startup:
* Self-contained Windows: No noticiable/measurable difference
* NugetPackageExplorer Startup:
* Self-contained Windows: No noticiable/measurable difference
** Risk
Medium.
The change is well scoped, but isn't trivial.
It affects all single-file apps.
** Master Branch
dotnet/runtime#32649
0 commit comments