always try to read symlink; only fall back to looking inside file
On Windows with Cygwin, checking out a git-annex repo will create symlinks on disk, so we need to always try to read the symlink, even when core.symlinks says they're not supported.
This commit is contained in:
parent
61a17fdc84
commit
e7936b1a34
1 changed files with 15 additions and 13 deletions
|
@ -28,25 +28,27 @@ isAnnexLink file = maybe Nothing (fileKey . takeFileName) <$> getAnnexLinkTarget
|
||||||
|
|
||||||
{- Gets the link target of a symlink.
|
{- Gets the link target of a symlink.
|
||||||
-
|
-
|
||||||
- On a filesystem that does not support symlinks, get the link
|
- On a filesystem that does not support symlinks, fall back to getting the
|
||||||
- target by looking inside the file. (Only return at first 8k of the file,
|
- link target by looking inside the file. (Only return at first 8k of the
|
||||||
- more than enough for any symlink target.)
|
- file, more than enough for any symlink target.)
|
||||||
-
|
-
|
||||||
- Returns Nothing if the file is not a symlink, or not a link to annex
|
- Returns Nothing if the file is not a symlink, or not a link to annex
|
||||||
- content.
|
- content.
|
||||||
-}
|
-}
|
||||||
getAnnexLinkTarget :: FilePath -> Annex (Maybe LinkTarget)
|
getAnnexLinkTarget :: FilePath -> Annex (Maybe LinkTarget)
|
||||||
getAnnexLinkTarget file = do
|
getAnnexLinkTarget file =
|
||||||
v <- ifM (coreSymlinks <$> Annex.getGitConfig)
|
check readSymbolicLink $
|
||||||
( liftIO $ catchMaybeIO $ readSymbolicLink file
|
check readfilestart $
|
||||||
, liftIO $ catchMaybeIO $ readfilestart file
|
return Nothing
|
||||||
)
|
|
||||||
case v of
|
|
||||||
Nothing -> return Nothing
|
|
||||||
Just l
|
|
||||||
| isLinkToAnnex l -> return v
|
|
||||||
| otherwise -> return Nothing
|
|
||||||
where
|
where
|
||||||
|
check getlinktarget fallback = do
|
||||||
|
v <- liftIO $ catchMaybeIO $ getlinktarget file
|
||||||
|
case v of
|
||||||
|
Just l
|
||||||
|
| isLinkToAnnex l -> return v
|
||||||
|
| otherwise -> return Nothing
|
||||||
|
Nothing -> fallback
|
||||||
|
|
||||||
readfilestart f = do
|
readfilestart f = do
|
||||||
h <- openFile f ReadMode
|
h <- openFile f ReadMode
|
||||||
fileEncoding h
|
fileEncoding h
|
||||||
|
|
Loading…
Reference in a new issue