check symlink before reading file
This is faster because when multiple files are in a directory, it gets cached.
This commit is contained in:
parent
4163344ed6
commit
c4f1465a81
2 changed files with 13 additions and 8 deletions
|
@ -301,7 +301,7 @@ unpaddedMaxPointerSz = 8192
|
||||||
- symlink does. Avoids a false positive in those cases.
|
- symlink does. Avoids a false positive in those cases.
|
||||||
- -}
|
- -}
|
||||||
isPointerFile :: RawFilePath -> IO (Maybe Key)
|
isPointerFile :: RawFilePath -> IO (Maybe Key)
|
||||||
isPointerFile f = catchDefaultIO Nothing $ do
|
isPointerFile f = catchDefaultIO Nothing $
|
||||||
#if defined(mingw32_HOST_OS)
|
#if defined(mingw32_HOST_OS)
|
||||||
checkcontentfollowssymlinks -- no symlinks supported on windows
|
checkcontentfollowssymlinks -- no symlinks supported on windows
|
||||||
#else
|
#else
|
||||||
|
@ -311,13 +311,10 @@ isPointerFile f = catchDefaultIO Nothing $ do
|
||||||
closeFd
|
closeFd
|
||||||
(\fd -> readhandle =<< fdToHandle fd)
|
(\fd -> readhandle =<< fdToHandle fd)
|
||||||
#else
|
#else
|
||||||
pointercontent <- checkcontentfollowssymlinks
|
ifM (isSymbolicLink <$> R.getSymbolicLinkStatus f)
|
||||||
if isJust pointercontent
|
|
||||||
then ifM (isSymbolicLink <$> R.getSymbolicLinkStatus f)
|
|
||||||
( return Nothing
|
( return Nothing
|
||||||
, return pointercontent
|
, checkcontentfollowssymlinks
|
||||||
)
|
)
|
||||||
else return Nothing
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
where
|
where
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 25"""
|
||||||
|
date="2021-06-14T15:52:37Z"
|
||||||
|
content="""
|
||||||
|
Found an optimisation that sped it up 50%, but this edge case is still
|
||||||
|
`O(N^2)`, so *shrug*.
|
||||||
|
"""]]
|
Loading…
Reference in a new issue