Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contenthash: improve the correctness of needsScan
Commit f724d6f ("contenthash: implement proper Linux symlink semantics for needsScan") fixed issues with needScan's handling of symlinks, but the logic used to figure out if a parent path is in the cache was incorrect in a couple of ways: 1. The optimisation in getFollowSymlinksCallback to avoid looking up / in the cache lead to the callback not being called when we go through /. The upshot is that needsScan(/non-existent-path) would always return true because we didn't check if / has been scanned. 2. Similarly, the logic of skipping a cache lookup if the path is the same as the current path meant that we skipped the first / lookup (because we start with currentPath=/). 3. Because needsScan would only store the _last_ good path, cases with symlink jumps to non-existent paths within directories already scanned would result in a re-scan that isn't necessary. Fix this by saving a set of prefix paths we have seen. Note that in combination with (1) and (2), if / has been scanned then needsScan will always return false now (because the / prefix is always checked against). Fixes: f724d6f ("contenthash: implement proper Linux symlink semantics for needsScan") Signed-off-by: Aleksa Sarai <[email protected]>
- Loading branch information