avoid clean filter trying to annex a pointer file
authorJoey Hess <joeyh@joeyh.name>
Wed, 9 Dec 2015 19:24:32 +0000 (15:24 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 9 Dec 2015 19:24:32 +0000 (15:24 -0400)
Command/Smudge.hs

index 7462963212d31bc77cc3648494156a67b6c2a0c6..9ce95d4ef223ce8759c9d2fe2ffc2e898673cb13 100644 (file)
@@ -54,22 +54,23 @@ smudge file = do
                                =<< catchMaybeIO (B.readFile content)
        stop
 
--- Clean filter decides if a file should be stored in the annex, and
--- outputs a pointer to its injested content.
+-- Clean filter is fed file content on stdin, decides if a file
+-- should be stored in the annex, and outputs a pointer to its
+-- injested content.
 clean :: FilePath -> CommandStart
 clean file = do
-       ifM (shouldAnnex file)
-               ( do
-                       k <- ingest file
-                       updateAssociatedFiles k file
-                       liftIO $ emitPointer k
-               , liftIO cat
-               )
+       b <- liftIO $ B.hGetContents stdin
+       if isJust (parseLinkOrPointer b)
+               then liftIO $ B.hPut stdout b
+               else ifM (shouldAnnex file)
+                       ( do
+                               k <- ingest file
+                               updateAssociatedFiles k file
+                               liftIO $ emitPointer k
+                       , liftIO $ B.hPut stdout b
+                       )
        stop
 
-cat :: IO ()
-cat = B.hGetContents stdin >>= B.hPut stdout
-
 shouldAnnex :: FilePath -> Annex Bool
 shouldAnnex file = do
        matcher <- largeFilesMatcher