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

Fix yay -Sc wiping ~/.cache/yay on 3rd question. #2175

Merged
merged 1 commit into from
May 22, 2023
Merged

Conversation

pteromys
Copy link
Contributor

@pteromys pteromys commented May 21, 2023

If you answer yes to

:: Do you want to remove all other AUR packages from cache? [Y/n]

then we run cleanAUR(), intending to remove subdirectories of ~/.cache/yay that do not share a name with installed packages not found in the sync repositories.

Where this was going wrong was cleanAUR's invocation was getting an empty map from dbExecutor.InstalledRemotePackages()—because InstalledRemotePackages only recomputed its result if installedRemotePkgMap was nil whereas NewExecutor initialized it to an empty map. The symptom was it emptied my ~/.cache/yay.

We do want a non-nil, empty installedRemotePkgMap to block recomputing (that is, to indicate the user really has no remote packages), so now NewExecutor initializes it to nil, and getPackageNamesBySource is responsible for making sure it's non-nil before writing to it.

Fixes #2152, which seems to have been introduced in 4626a04.

@pteromys pteromys requested a review from Jguer as a code owner May 21, 2023 03:31
@Jguer
Copy link
Owner

Jguer commented May 22, 2023

Should the fix not be setting the installedRemotePkgMap to nil on instantiation?

In this case if the user does not have remote packages it will always be recomputed

If you answer yes to
    :: Do you want to remove all other AUR packages from cache? [Y/n]
then we run cleanAUR(), intending to remove subdirectories of
~/.cache/yay that do not share a name with installed packages not
found in the sync repositories.

Where this was going wrong was cleanAUR() was getting an empty map from
dbExecutor.InstalledRemotePackages()---because InstalledRemotePackages
only recomputes its result if installedRemotePkgMap is nil, whereas
NewExecutor initialized it to an empty map. The symptom was it emptied
my ~/.cache/yay.

We do want a non-nil, empty installedRemotePkgMap to block recomputing
(that is, to indicate the user really has no remote packages), so now
NewExecutor initializes it to nil, and getPackageNamesBySource is
responsible for making sure it's non-nil before writing to it.

Fixes Jguer#2152, which seems to have been introduced in
4626a04.
@pteromys
Copy link
Contributor Author

Oh, yes, that would be better. Updated!

@Jguer
Copy link
Owner

Jguer commented May 22, 2023

Thanks for the PR and the fix @pteromys 😃 , I'm merging it as soon as it passes the CI

@Jguer Jguer merged commit d33bf88 into Jguer:next May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

yay --aur -Sc no longer keep installed AUR package cache folders
2 participants