cleanup2
This commit is contained in:
parent
99b2029236
commit
ff998a9a67
1 changed files with 27 additions and 31 deletions
58
Annex.hs
58
Annex.hs
|
@ -65,6 +65,7 @@ annexFile state file = inBackend file err $ do
|
||||||
then error $ "not a regular file: " ++ file
|
then error $ "not a regular file: " ++ file
|
||||||
else return ()
|
else return ()
|
||||||
setup key backend = do
|
setup key backend = do
|
||||||
|
logStatus state key ValuePresent
|
||||||
let dest = annexLocation state backend key
|
let dest = annexLocation state backend key
|
||||||
let reldest = annexLocationRelative state backend key
|
let reldest = annexLocationRelative state backend key
|
||||||
createDirectoryIfMissing True (parentDir dest)
|
createDirectoryIfMissing True (parentDir dest)
|
||||||
|
@ -73,7 +74,6 @@ annexFile state file = inBackend file err $ do
|
||||||
gitRun (repo state) ["add", file]
|
gitRun (repo state) ["add", file]
|
||||||
gitRun (repo state) ["commit", "-m",
|
gitRun (repo state) ["commit", "-m",
|
||||||
("git-annex annexed " ++ file), file]
|
("git-annex annexed " ++ file), file]
|
||||||
logStatus state key ValuePresent
|
|
||||||
linkTarget file =
|
linkTarget file =
|
||||||
-- relies on file being relative to the top of the
|
-- relies on file being relative to the top of the
|
||||||
-- git repo; just replace each subdirectory with ".."
|
-- git repo; just replace each subdirectory with ".."
|
||||||
|
@ -88,41 +88,37 @@ annexFile state file = inBackend file err $ do
|
||||||
unannexFile :: State -> FilePath -> IO ()
|
unannexFile :: State -> FilePath -> IO ()
|
||||||
unannexFile state file = notinBackend file err $ \(key, backend) -> do
|
unannexFile state file = notinBackend file err $ \(key, backend) -> do
|
||||||
dropFile state backend key
|
dropFile state backend key
|
||||||
cleanup key backend
|
logStatus state key ValueMissing
|
||||||
|
let src = annexLocation state backend key
|
||||||
|
removeFile file
|
||||||
|
gitRun (repo state) ["rm", file]
|
||||||
|
gitRun (repo state) ["commit", "-m",
|
||||||
|
("git-annex unannexed " ++ file), file]
|
||||||
|
-- git rm deletes empty directories;
|
||||||
|
-- put them back
|
||||||
|
createDirectoryIfMissing True (parentDir file)
|
||||||
|
renameFile src file
|
||||||
|
return ()
|
||||||
where
|
where
|
||||||
err = error $ "not annexed " ++ file
|
err = error $ "not annexed " ++ file
|
||||||
cleanup key backend = do
|
|
||||||
let src = annexLocation state backend key
|
|
||||||
removeFile file
|
|
||||||
gitRun (repo state) ["rm", file]
|
|
||||||
gitRun (repo state) ["commit", "-m",
|
|
||||||
("git-annex unannexed " ++ file), file]
|
|
||||||
-- git rm deletes empty directories;
|
|
||||||
-- put them back
|
|
||||||
createDirectoryIfMissing True (parentDir file)
|
|
||||||
renameFile src file
|
|
||||||
logStatus state key ValueMissing
|
|
||||||
return ()
|
|
||||||
|
|
||||||
{- Transfers the file from a remote. -}
|
{- Transfers the file from a remote. -}
|
||||||
annexGetFile :: State -> FilePath -> IO ()
|
annexGetFile :: State -> FilePath -> IO ()
|
||||||
annexGetFile state file = do
|
annexGetFile state file = notinBackend file err $ \(key, backend) -> do
|
||||||
r <- lookupFile file
|
inannex <- inAnnex state backend key
|
||||||
case (r) of
|
if (inannex)
|
||||||
Nothing -> error $ "not annexed " ++ file
|
then return ()
|
||||||
Just (key, backend) -> do
|
else do
|
||||||
inannex <- inAnnex state backend key
|
let dest = annexLocation state backend key
|
||||||
if (inannex)
|
createDirectoryIfMissing True (parentDir dest)
|
||||||
then return ()
|
success <- retrieveFile state backend key dest
|
||||||
else do
|
if (success)
|
||||||
let dest = annexLocation state backend key
|
then do
|
||||||
createDirectoryIfMissing True (parentDir dest)
|
logStatus state key ValuePresent
|
||||||
success <- retrieveFile state backend key dest
|
return ()
|
||||||
if (success)
|
else error $ "failed to get " ++ file
|
||||||
then do
|
where
|
||||||
logStatus state key ValuePresent
|
err = error $ "not annexed " ++ file
|
||||||
return ()
|
|
||||||
else error $ "failed to get " ++ file
|
|
||||||
|
|
||||||
{- Indicates a file is wanted. -}
|
{- Indicates a file is wanted. -}
|
||||||
annexWantFile :: State -> FilePath -> IO ()
|
annexWantFile :: State -> FilePath -> IO ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue