Skip to content

Commit

Permalink
Fixed possible race condition in fileHasChanged function.
Browse files Browse the repository at this point in the history
  • Loading branch information
eklingen committed Dec 12, 2024
1 parent 6afab1b commit 45a6781
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# Changelog

v1.1.3 - Fixed possible race condition in `fileHasChanged` function.
v1.1.2 - Some small changes for Windows compatibility
v1.1.1 - Added `enableBypass` option to the constructor, to enable quick disabling of the whole caching mechanism.
v1.1.0 - Addd `removeEntriesByKeys(...key)` function.
Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ export default class FileHashCache {
return true
}

const fileKey = relativePath(this.projectRoot, filepath)
const fileHash = await this.#getFileHash(filepath, encoding)

if (!this.hashCache[key]) {
await this.load(key)
}

const fileKey = relativePath(this.projectRoot, filepath)
const fileHash = await this.#getFileHash(filepath, encoding)
const cachedHash = this.hashCache[key][fileKey] || ''
const fileHasChanged = (fileHash !== cachedHash)

Expand Down

0 comments on commit 45a6781

Please sign in to comment.