add generalized linkAnnex'
authorJoey Hess <joeyh@joeyh.name>
Thu, 10 Dec 2015 20:07:50 +0000 (16:07 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 10 Dec 2015 20:08:19 +0000 (16:08 -0400)
Annex/Content.hs
doc/todo/smudge.mdwn

index 44f1ad0a0242533d9583f9eac0ccfb159805f013..10a59ae95b9f1b4663a428ac269de0a805ee25b5 100644 (file)
@@ -25,6 +25,7 @@ module Annex.Content (
        checkDiskSpace,
        moveAnnex,
        linkAnnex,
+       linkAnnex',
        LinkAnnexResult(..),
        sendAnnex,
        prepSendAnnex,
@@ -514,15 +515,21 @@ populatePointerFile k obj f = go =<< isPointerFile f
 linkAnnex :: Key -> FilePath -> Annex LinkAnnexResult
 linkAnnex key src = do
        dest <- calcRepo (gitAnnexLocation key)
+       modifyContent dest $ linkAnnex' key src dest
+
+{- Hard links (or copies) src to dest, one of which should be the
+ - annex object. -}
+linkAnnex' :: Key -> FilePath -> FilePath -> Annex LinkAnnexResult
+linkAnnex' key src dest = 
        ifM (liftIO $ doesFileExist dest)
                ( return LinkAnnexNoop
-               , modifyContent dest $
-                       ifM (liftIO $ createLinkOrCopy src dest)
-                               ( do
-                                       Database.Keys.storeInodeCaches key [dest, src]
-                                       return LinkAnnexOk
-                               , return LinkAnnexFailed
-                               )
+               , ifM (liftIO $ createLinkOrCopy src dest)
+                       ( do
+                               thawContent dest
+                               Database.Keys.storeInodeCaches key [dest, src]
+                               return LinkAnnexOk
+                       , return LinkAnnexFailed
+                       )
                )
 
 data LinkAnnexResult = LinkAnnexOk | LinkAnnexFailed | LinkAnnexNoop
index 6259d4a276bc17458c15a88eb21958e7773e86c9..dd990afc71e4c25e87e627aaca9eb44ca669d9ef 100644 (file)
@@ -325,6 +325,8 @@ files to be unlocked, while the indirect upgrades don't touch the files.
 
 #### implementation todo list
 
+* linkAnnex should check disk reserve when it falls back to copying the
+  file.
 * Reconcile staged changes into the associated files database, whenever
   the database is queried.
 * See if the cases where the Keys database is not used can be