-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add symlink field to file metadata and cache
Summary: This adds another entry to the `FileMetadata` tuple used throughout `metro-file-map`, to be used to compactly represent: a) Whether a file is regular or a symlink b) The symlink target, if known. In doing so, it changes the persisted cache format - so this diff also bumps the `CACHE_BREAKER` key. Note that because Metro only passes `enableSymlinks: false` to the `metro-file-map`, and this config isn't exposed to the user, *all* crawl results should currently have a `0` entry. ## Storing symlinks in the `files` map I considered storing symlinks in a separate `Map` alongside `files`, which is slightly more compact. Ultimately though this is more difficult to work with - almost every lookup becomes two lookups and it's rare that we'd need to iterate over one but not the other. We could revisit this if we ever separate the serialised structure from the working-copy structure. ## Type: `0 | 1 | string` There are a couple of considerations in this type, which aims to compactly capture both the type and (optionally) the symlink target: - As an intermediate state, it's useful to be able to record that a file is a symlink without necessarily knowing the target. In particular, this allows us to `readlink` downstream of non-Watchman crawlers and watchers that can't natively provide the target, e.g. in the multi-thread `processFile` phase, or indeed on demand. - We use `0 | 1` as opposed to `boolean` for serialised compactness, following the precedent of `H.VISITED`. (`null` would be ambiguous in this context.) NOTE: `metadata[H.SYMLINK] === 0` should be used to check for regular files at the low level - truthiness is unreliable because [POSIX says](https://pubs.opengroup.org/onlinepubs/9699919799/functions/symlink.html) the target is an arbitrary string (including an empty string) - (in practice - macOS allows empty symlinks, linux doesn't). Reviewed By: huntie Differential Revision: D42131590 fbshipit-source-id: 1fa39576988159887b88057f003de6018b85a583
- Loading branch information
1 parent
2d60a02
commit 58c88b8
Showing
9 changed files
with
141 additions
and
62 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
Oops, something went wrong.