Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cached file listing outdated packages is not updated when there are no changes #978

Closed
4 tasks done
gep13 opened this issue Jan 26, 2023 · 1 comment
Closed
4 tasks done
Assignees
Labels
5 - Released The issue has been resolved, and released to the public for consumption Bug Issues where something has happened which was not expected or intended
Milestone

Comments

@gep13
Copy link
Member

gep13 commented Jan 26, 2023

Checklist

  • I have verified this is the correct repository for opening this issue.
  • I have verified no other issues exist related to my problem.
  • I have verified this is not an issue for a specific package.
  • I have verified this issue is not security related.

What You Are Seeing?

When configured to do so, Chocolatey GUI figures out all of the outdated packages that are currently installed on the system and writes this information to a file in the users AppData\Local\Chocolatey GUI folder. This file is called outdatedPackages.xml. The idea is that this cached information will be used to display the outdated packages within the UI, without having to always fetch this information. There is also a setting within the Chocolatey GUI called oudatedPackagesCacheDurationsInMinutes which defaults to 60. This setting is used to tell Chocolatey GUI how long it should wait before invalidating the cached file.

Currently, when the 60 minutes expires, Chocolatey GUI correctly fetches the outdated information and attempts to update the cached file, but when there are no changes to the information (i.e. the hash of the file is exactly the same) the file never gets updated, and continues to have the original modified time.

As a result, when the outdated packages is never changing, Chocolatey GUI will continue to unnecessarily fetch outdated information every time, even though the information was fetched, the file was never updated.

This is due to the usage of the XmlService in the Chocolatey.Lib, where it only serializes a file to disk, when it is known that that file has changed. In some cases, this is exactly what you want, but the use case in Chocolatey GUI relies on the timestamp applied to the file when it modified to know that an action is required.

What is Expected?

When information about outdated packages is fetched, the cached file should always be written, regardless of whether the information is the same or not. This will ensure correct usage of the cached file, and prevent unnecessary fetching of information.

How Did You Get This To Happen?

  1. Install Chocolatey GUI
  2. Set oudatedPackagesCacheDurationsInMinutes to a lower value so that is isn't necessary to wait 60 minutes to see this happen
  3. Install an earlier version of a package, for example vlc choco install vlc --version 3.0.16
  4. Open Chocolatey GUI and verify that the package is correctly marked as outdated
  5. Open the users AppData\Local\Chocolatey GUI folder and inspect the modified date of the outdatedPackages.xml file
  6. Close Chocolatey GUI
  7. Wait the length of time in the setting above
  8. Open Chocolatey GUI and verify that outdated packages information is fetched (this can be seen by the progress bar at the bottom of the screen)
  9. Check the outdatedPackages.xml modified date, and verify that it hasn't changed

System Details

  • Operating System: 10.0.17763.0
  • Windows PowerShell version: 5.1.17763.3770
  • Chocolatey CLI Version: 1.2.1
  • Chocolatey Licensed Extension version: 5.0.1
  • Chocolatey License type: Business
  • Terminal/Emulator: WIndows PowerShell

Installed Packages

The currently installed packages has no bearing on this bug.

Output Log

N/A

Additional Context

This was found during investigations into what was required to bring Chocolatey GUI Licensed Extension up to date with the latest alpha version of Chocolatey.Lib.

@gep13 gep13 added the Bug Issues where something has happened which was not expected or intended label Jan 26, 2023
@gep13 gep13 self-assigned this Jan 26, 2023
@gep13 gep13 added the 0 - Backlog Issue is accepted, but is not ready to be worked on or not in current sprint label Jan 26, 2023
@gep13 gep13 added this to the 1.1.1 milestone Jan 26, 2023
gep13 added a commit that referenced this issue Jan 26, 2023
Due to the way that the XmlService class works, if the information
about the outdated packages is the same as what is currently present in
the existing file, the file isn't updated. This is because the
XmlService compares the hash, and chooses to not update the file,
leaving it in tact.  Depending on the use case, this is exactly the
right thing to do, but for Chocolatey GUI, we use the date time of when
the file was created as a trigger as to whether another outdated check
is required.  As a result, multiple repeated outdated checks can happen
when not required.

This commit first deletes the cached file if it exists, and a new
outdated check was performed, writing a new file each time. This way,
the outdated check will only be performed once, when required.
@gep13 gep13 added 2 - Working A user or team member has started working on the issue and removed 0 - Backlog Issue is accepted, but is not ready to be worked on or not in current sprint labels Jan 26, 2023
@gep13 gep13 closed this as completed Jan 26, 2023
@gep13 gep13 added 4 - Done Code has been added to the repository, and has been reviewed by a team member and removed 2 - Working A user or team member has started working on the issue labels Jan 26, 2023
gep13 added a commit that referenced this issue Jan 26, 2023
* hotfix/1.1.1:
  (#977) Ensure that the correct public key is used
  (#977) Change variable names to be more specific
  (maint) Remove duplicates from csproj files
  (#978) Always delete outdated cache file
@choco-bot
Copy link

🎉 This issue has been resolved in version 1.1.1 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

gep13 added a commit that referenced this issue Jan 26, 2023
* hotfix/1.1.1:
  (#977) Ensure that the correct public key is used
  (#977) Change variable names to be more specific
  (maint) Remove duplicates from csproj files
  (#978) Always delete outdated cache file
  (maint) add/update 3rd party licenses information
  (build) Allow building with Visual Studio 2022
  (build) Update to latest Chocolatey.Cake.Recipe
@gep13 gep13 added 5 - Released The issue has been resolved, and released to the public for consumption and removed 4 - Done Code has been added to the repository, and has been reviewed by a team member labels Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Released The issue has been resolved, and released to the public for consumption Bug Issues where something has happened which was not expected or intended
Projects
None yet
Development

No branches or pull requests

2 participants