Skip to content
New issue

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

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

Already on GitHub? # to your account

allow deletions of indexes, handle null integrity values in compact better #55

Closed
wants to merge 2 commits into from

Conversation

nlf
Copy link
Contributor

@nlf nlf commented May 20, 2021

this provides an option to cacache.rm/cacache.rm.entry that allows a user to indicate they wish for the entire index file to be removed rather than appending a new entry with an integrity of null. this is how make-fetch-happen will invalidate the cache for a given URL

it also enhances cacache.index.compact to accept a validateEntry option that allows a user to keep entries with null integrities, so long as they are considered valid. this is how make-fetch-happen will keep index entries that have a null integrity (redirect responses have no body) and still be able to prune out older entries with a null integrity.

References

Related to npm/make-fetch-happen#49

Copy link
Contributor

@isaacs isaacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'll fixup the comment about keepMissingIntegrityWhenSet and land it.


If `opts.validateEntry` is not provided, however, every entry in the index will
be deduplicated and kept until the first `null` integrity is reached, removing
all entries that were written before the `null`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if I'm reading this correctly, adding a null index entry and then a new index entry, then compacting is somewhat the same as doing removeAll and then adding the new one? Like, the null means "ignore all that came before"?

// entries come first in order to make looping through them easier
// the true passed to formatEntry tells it to keep null
// integrity values, if they made it this far it's because
// the user specified a metadata field in keepMissingIntegrityWhenSet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is keepMissingIntegrityWhenSet still a thing? I thought the caller just provides their own validateEntry function to do that.

@isaacs isaacs closed this in 8892a92 May 25, 2021
@lukekarrys lukekarrys deleted the nlf/more-enhancements branch November 4, 2022 03:41
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants