blob: e8e839e4fa592bf031feb5a7bddae77b07c0c8a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
{- git-annex command
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Import where
import Common.Annex
import Command
import qualified Annex
import qualified Command.Add
def :: [Command]
def = [notDirect $ notBareRepo $ command "import" paramPaths seek
"move and add files from outside git working copy"]
seek :: [CommandSeek]
seek = [withPathContents start]
start :: (FilePath, FilePath) -> CommandStart
start (srcfile, destfile) =
ifM (liftIO $ isRegularFile <$> getSymbolicLinkStatus srcfile)
( do
showStart "import" destfile
next $ perform srcfile destfile
, stop
)
perform :: FilePath -> FilePath -> CommandPerform
perform srcfile destfile = do
whenM (liftIO $ doesFileExist destfile) $
unlessM (Annex.getState Annex.force) $
error $ "not overwriting existing " ++ destfile ++
" (use --force to override)"
liftIO $ createDirectoryIfMissing True (parentDir destfile)
liftIO $ moveFile srcfile destfile
Command.Add.perform destfile
|