microsoft / microsoft/winget-cli

COM DownloadPackagesAsync Cache Issue

Open
#5,303 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

Brief description of your issue

BUG: C# application using the InProc COM API does not properly cleanup/dispose of files/resources when downloading a package (using the Winget source).

Description:
When using the InProc COM API's download command to download a package from the WinGet community repository, there is a temporary(should be at least) SQLite Index file that is not being properly deleted.
The file can be found inside of the %AppData% folder (see below):
C:\Users%USERNAME%\AppData\Local\Temp\WinGet\defaultState
The file appears to be a temporary SQLite Index file that has a GUID for its name and is generally around 3MB large. E.g: {CE955181-3EC7-4625-8B7A-BF5B8E07DACF}
The file does not get properly removed upon completion of the download command.

NOTE:This issue does not occur when using the regular winget C++ client as the files/resources are properly removed.
ADDITIONAL INFO:

  1. the SQLite index file is neither generated or persisted when using a REST source. (this is likely by design)
  2. The OutOfProc COM API was not tested so we are unaware if the problem exists using the OOP COM API.
Steps to reproduce

Download the MinimalCallers project inside of samples and modify the Program.cs of C#_WinGet_InProc to download a package.

I've attached an example project below where the issue occurs.

MinimalCallers.zip

Expected behavior

When the COM API is exiting and the destructors are being invoked, ~ManagedFile should properly delete the temporary SQLite file.

Actual behavior

Destructor does not actually delete the temporary file with the COM API.

Environment
Windows Package Manager v1.10.340
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.26100.3476
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.25.340.0

Winget Directories
-----------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads
Configuration Modules              %LOCALAPPDATA%\Microsoft\WinGet\Configuration\Modules

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled
ProxyCommandLineOptions                   Disabled
DefaultProxy                              Disabled

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the samples/MinimalCallers project, especially Program.cs for C#_WinGet_InProc, and trace the InProc COM download path around the mentioned ~ManagedFile destructor. Reproduce the download against the WinGet source and inspect whether the temporary SQLite index under %AppData%\Local\Temp\WinGet\defaultState remains afterward. Done means the file is cleaned up for the InProc COM API as it is for the regular C++ client.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp, sqlite
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.