Skip to content

Commit

Permalink
Gather symlink targets on crawl/change processing
Browse files Browse the repository at this point in the history
Summary:
The groundwork has been done to store symlink targets in `metro-file-map`'s in-memory (and persisted) map, but we're not yet reading link targets.

This diff adds a `readLink` worker option and sets it when appropriate within `_processFile`, and delegates to the worker for consistency with other operations that require a "visit" to gather metadata subsequent to a crawl result or change event.

Symlink targets will then be stored for all symlinks in the cache, and we'll avoid any IO if their modification time doesn't change.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D42546808

fbshipit-source-id: 5c9737971f50dc90ade43f709ef896124023203e
  • Loading branch information
robhogan authored and facebook-github-bot committed Jan 18, 2023
1 parent 51df674 commit 5ae4b0d
Show file tree
Hide file tree
Showing 6 changed files with 307 additions and 132 deletions.
14 changes: 14 additions & 0 deletions packages/metro-file-map/src/HasteFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export default class HasteFS implements MutableFileSystem {
if (visitResult.dependencies != null) {
metadata[H.DEPENDENCIES] = visitResult.dependencies;
}

if (visitResult.symlinkTarget != null) {
metadata[H.SYMLINK] = visitResult.symlinkTarget;
}
}

getSerializableSnapshot(): FileData {
Expand All @@ -93,6 +97,16 @@ export default class HasteFS implements MutableFileSystem {
return (fileMetadata && fileMetadata[H.SIZE]) ?? null;
}

getSymlinkTarget(file: Path): ?string {
const fileMetadata = this._getFileData(file);
if (fileMetadata == null) {
return null;
}
return typeof fileMetadata[H.SYMLINK] === 'string'
? fileMetadata[H.SYMLINK]
: null;
}

getType(file: Path): ?('f' | 'l') {
const fileMetadata = this._getFileData(file);
if (fileMetadata == null) {
Expand Down
Loading

0 comments on commit 5ae4b0d

Please sign in to comment.