diff options
author | Joey Hess <joey@kitenet.net> | 2013-05-14 14:18:47 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-05-14 14:18:47 -0400 |
commit | c2f6f82a146339bb4b94acff1aae4f12ad023a08 (patch) | |
tree | 1906ce0ca41a932fe0bd79fcd93298b165f141f7 /Annex/Link.hs | |
parent | 41e6ca8074d82bf92f9378632d55483c3d9e8a8e (diff) |
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.
Diffstat (limited to 'Annex/Link.hs')
-rw-r--r-- | Annex/Link.hs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/Annex/Link.hs b/Annex/Link.hs index 24ec6c7c9..1b4aacfac 100644 --- a/Annex/Link.hs +++ b/Annex/Link.hs @@ -28,25 +28,27 @@ isAnnexLink file = maybe Nothing (fileKey . takeFileName) <$> getAnnexLinkTarget {- Gets the link target of a symlink. - - - On a filesystem that does not support symlinks, get the link - - target by looking inside the file. (Only return at first 8k of the file, - - more than enough for any symlink target.) + - On a filesystem that does not support symlinks, fall back to getting the + - link target by looking inside the file. (Only return at first 8k of the + - file, more than enough for any symlink target.) - - Returns Nothing if the file is not a symlink, or not a link to annex - content. -} getAnnexLinkTarget :: FilePath -> Annex (Maybe LinkTarget) -getAnnexLinkTarget file = do - v <- ifM (coreSymlinks <$> Annex.getGitConfig) - ( liftIO $ catchMaybeIO $ readSymbolicLink file - , liftIO $ catchMaybeIO $ readfilestart file - ) - case v of - Nothing -> return Nothing - Just l - | isLinkToAnnex l -> return v - | otherwise -> return Nothing +getAnnexLinkTarget file = + check readSymbolicLink $ + check readfilestart $ + return Nothing 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 h <- openFile f ReadMode fileEncoding h |