diff options
author | Joey Hess <joey@kitenet.net> | 2013-02-18 02:35:38 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-02-18 02:35:38 -0400 |
commit | db27cde123c4b2fd0e46f7f2a097e7a42451d844 (patch) | |
tree | 6dd0b30c70c044e3501d2d29d97bb8218fb6febf /Annex/Link.hs | |
parent | 548f9e629ff0f527b2b631012e406ad9f3f9a8a2 (diff) |
types
Diffstat (limited to 'Annex/Link.hs')
-rw-r--r-- | Annex/Link.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Annex/Link.hs b/Annex/Link.hs index f35c069ee..6cfad4975 100644 --- a/Annex/Link.hs +++ b/Annex/Link.hs @@ -19,6 +19,8 @@ import qualified Git.UpdateIndex import qualified Annex.Queue import Git.Types +type LinkTarget = String + {- Checks if a file is a link to a key. -} isAnnexLink :: FilePath -> Annex (Maybe Key) isAnnexLink file = maybe Nothing (fileKey . takeFileName) <$> getAnnexLinkTarget file @@ -32,7 +34,7 @@ isAnnexLink file = maybe Nothing (fileKey . takeFileName) <$> getAnnexLinkTarget - Returns Nothing if the file is not a symlink, or not a link to annex - content. -} -getAnnexLinkTarget :: FilePath -> Annex (Maybe String) +getAnnexLinkTarget :: FilePath -> Annex (Maybe LinkTarget) getAnnexLinkTarget file = do v <- ifM (coreSymlinks <$> Annex.getGitConfig) ( liftIO $ catchMaybeIO $ readSymbolicLink file @@ -51,20 +53,20 @@ getAnnexLinkTarget file = do - it's staged as such, so use addAnnexLink when adding a new file or - modified link to git. -} -makeAnnexLink :: String -> FilePath -> Annex () +makeAnnexLink :: LinkTarget -> FilePath -> Annex () makeAnnexLink linktarget file = ifM (coreSymlinks <$> Annex.getGitConfig) ( liftIO $ createSymbolicLink linktarget file , liftIO $ writeFile file linktarget ) {- Creates a link on disk, and additionally stages it in git. -} -addAnnexLink :: String -> FilePath -> Annex () +addAnnexLink :: LinkTarget -> FilePath -> Annex () addAnnexLink linktarget file = do makeAnnexLink linktarget file stageSymlink file =<< hashSymlink linktarget {- Injects a symlink target into git, returning its Sha. -} -hashSymlink :: String -> Annex Sha +hashSymlink :: LinkTarget -> Annex Sha hashSymlink linktarget = inRepo $ Git.HashObject.hashObject BlobObject linktarget {- Stages a symlink to the annex, using a Sha of its target. -} |