-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metro-file-map: Implement getOrComputeSha1 (lazy hashing 2/3)
Summary: ## Stack In this stack we're moving towards metro-file-map being able to *lazily* compute file metadata - in particular the SHA1 hash - only when required by the transformer. More context in #1325 (comment) ## Implementing a lazy hashing API in metro-file-map This diff adds a new async `getOrComputeSha1` API to the exposed `FileSystem` interface implemented by `TreeFS`. `TreeFS` is provided during construction with a means to use the `FileProcessor`. - In common with other `FileSystem` methods, it returns null if the path does not point to a watched regular file. - It dereferences symlinks to pass only real, absolute paths to `processFile`, so that it accepts the same range of inputs as `getSha1`. - Caches SHA1 in metro-file-map, so that it may be persisted. Safely clears the value on modification, including when modification races processing. - Emits a `metadata` event to inform auto-saving caches about a change to internal state. - This diff does not exercise the new API, except in tests. - TreeFS consumers are required to pass `processFile`, non-breaking as this API is [experimental](https://github.com/facebook/metro/blob/main/packages/metro-file-map/README.md#experimental-metro-file-map). Changelog: Internal Differential Revision: D69123130
- Loading branch information
1 parent
e4cbfa7
commit a995194
Showing
6 changed files
with
202 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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