summaryrefslogtreecommitdiff
path: root/Command/Clean.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Command/Clean.hs')
-rw-r--r--Command/Clean.hs68
1 files changed, 0 insertions, 68 deletions
diff --git a/Command/Clean.hs b/Command/Clean.hs
deleted file mode 100644
index 15dcdfacb..000000000
--- a/Command/Clean.hs
+++ /dev/null
@@ -1,68 +0,0 @@
-{- git-annex command
- -
- - Copyright 2015 Joey Hess <id@joeyh.name>
- -
- - Licensed under the GNU GPL version 3 or higher.
- -}
-
-module Command.Clean where
-
-import Common.Annex
-import Command
-import Annex.Content
-import Annex.MetaData
-import Annex.FileMatcher
-import Types.KeySource
-import Types.Key
-import Backend
-import Logs.Location
-
-import qualified Data.ByteString.Lazy as B
-
-cmd :: Command
-cmd = noMessages $ dontCheck repoExists $
- command "clean" SectionPlumbing
- "git clean filter"
- paramFile (withParams seek)
-
-seek :: CmdParams -> CommandSeek
-seek = withWords start
-
-start :: [String] -> CommandStart
-start [file] = do
- ifM (shouldAnnex file)
- ( do
- k <- ingest file
- liftIO $ putStrLn (key2file k)
- , liftIO $ B.hGetContents stdin >>= B.hPut stdout -- cat file
- )
- stop
-start [] = error "clean filter run without filename; upgrade git"
-start _ = error "clean filter passed multiple filenames"
-
-shouldAnnex :: FilePath -> Annex Bool
-shouldAnnex file = do
- matcher <- largeFilesMatcher
- checkFileMatcher matcher file
-
-ingest :: FilePath -> Annex Key
-ingest file = do
- backend <- chooseBackend file
- let source = KeySource
- { keyFilename = file
- , contentLocation = file
- , inodeCache = Nothing
- }
- k <- fst . fromMaybe (error "failed to generate a key")
- <$> genKey source backend
- -- Hard link (or copy) file content to annex
- -- to prevent it from being lost when git checks out
- -- a branch not containing this file.
- r <- linkAnnex k file
- case r of
- LinkAnnexFailed -> error "Problem adding file to the annex"
- LinkAnnexOk -> logStatus k InfoPresent
- LinkAnnexNoop -> noop
- genMetaData k file
- =<< liftIO (getFileStatus file)
- return k