fix: update cache when watching box files#5790
Open
stevenjoezhang wants to merge 1 commit into
Open
Conversation
How to testgit clone -b fix/watch-cache-status https://github.com/hexojs/hexo.git
cd hexo
npm install
npm test |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses #5747 by ensuring the Box watcher updates (and cleans up) the cache when files are created/changed/deleted during watch mode, preventing subsequent watch restarts from incorrectly treating previously-seen files as newly created.
Changes:
- Use cache-based status detection (
Cache.compareFile) forwatch()add/change events so cache entries are created/updated during watch. - Remove cache entries on
unlinkevents before processing deletes. - Add a regression test asserting that a watched “create” inserts cache and results in
skipon a subsequentprocess()run.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/box/index.ts |
Updates watch event handling to derive file status from cache and removes cache entries on unlink. |
test/scripts/box/box.ts |
Adds/extends watch-mode tests to validate cache insertion on create and cache removal on delete. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+27
to
+30
| interface FileStatus { | ||
| type: string; | ||
| path: string; | ||
| } |
Comment on lines
243
to
246
| watcher.on('unlink', path => { | ||
| this._processFile(File.TYPE_DELETE, getPath(path)); | ||
| const filePath = getPath(path); | ||
| this._removeFileCache(filePath).then(() => this._processFile(File.TYPE_DELETE, filePath)); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does it do?
Issue resolved: #5747
Screenshots
Pull request tasks