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

glob-cache: update cache file when changed, automatically #196

Open
tunnckoCore opened this issue Jun 29, 2022 · 2 comments
Open

glob-cache: update cache file when changed, automatically #196

tunnckoCore opened this issue Jun 29, 2022 · 2 comments

Comments

@tunnckoCore
Copy link
Owner

tunnckoCore commented Jun 29, 2022

Seems like currently, it detects that the file has changed, but doesn't update the cache to the new state. Thus, it always hits the changed hook.

It's easy like

// Update the changed file's cache,
// Note: maybe we should handle that on glob-cache automatically?
await cacache.put(cacheLocation, file.path, file.contents);

on the if ctx.changed, and after the call of hooks.changed.

@tunnckoCore
Copy link
Owner Author

tunnckoCore commented Jun 30, 2022

Use cacache.verify after the loop, and cacache.rm.content old content on changed.

Also add done/finish hook.

edit:

Seems like when you call verify it automatically cleans up the old content file and the index file. So, the only needed is to call it once at the end of all, such as in done hook.

The done hook is handy, if you don't want to include cacache as dep in the upper module. Or because version collisions. This way you use the same cacache version, as glob-cache one.

Make the default done hook do just that cacache.verify.

@tunnckoCore
Copy link
Owner Author

Do not read the files by default.

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

No branches or pull requests

1 participant