atomic file retrieval from backends
This commit is contained in:
parent
8398b9ab4a
commit
a020b0c25c
4 changed files with 22 additions and 10 deletions
|
@ -156,13 +156,16 @@ getCmd file = notinBackend file err $ \(key, backend) -> do
|
|||
showStart "get" file
|
||||
g <- Annex.gitRepo
|
||||
let dest = annexLocation g key
|
||||
liftIO $ createDirectoryIfMissing True (parentDir dest)
|
||||
success <- Backend.retrieveKeyFile backend key dest
|
||||
let tmp = (annexTmpLocation g) ++ (keyFile key)
|
||||
liftIO $ createDirectoryIfMissing True (parentDir tmp)
|
||||
success <- Backend.retrieveKeyFile backend key tmp
|
||||
if (success)
|
||||
then do
|
||||
liftIO $ renameFile tmp dest
|
||||
logStatus key ValuePresent
|
||||
showEndOk
|
||||
else showEndFail "get" file
|
||||
else do
|
||||
showEndFail "get" file
|
||||
where
|
||||
err = error $ "not annexed " ++ file
|
||||
|
||||
|
|
9
Core.hs
9
Core.hs
|
@ -29,6 +29,8 @@ startup flags = do
|
|||
shutdown :: Annex ()
|
||||
shutdown = do
|
||||
g <- Annex.gitRepo
|
||||
|
||||
-- handle pending commits
|
||||
nocommit <- Annex.flagIsSet NoCommit
|
||||
needcommit <- Annex.flagIsSet NeedCommit
|
||||
if (needcommit && not nocommit)
|
||||
|
@ -36,6 +38,13 @@ shutdown = do
|
|||
"git-annex log update", gitStateDir g]
|
||||
else return ()
|
||||
|
||||
-- clean up any files left in the temp directory
|
||||
let tmp = annexTmpLocation g
|
||||
exists <- liftIO $ doesDirectoryExist tmp
|
||||
if (exists)
|
||||
then liftIO $ removeDirectoryRecursive $ tmp
|
||||
else return ()
|
||||
|
||||
{- configure git to use union merge driver on state files, if it is not
|
||||
- already -}
|
||||
gitAttributes :: Git.Repo -> IO ()
|
||||
|
|
|
@ -7,7 +7,8 @@ module Locations (
|
|||
keyFile,
|
||||
fileKey,
|
||||
annexLocation,
|
||||
annexLocationRelative
|
||||
annexLocationRelative,
|
||||
annexTmpLocation
|
||||
) where
|
||||
|
||||
import Data.String.Utils
|
||||
|
@ -36,6 +37,11 @@ annexLocation r key =
|
|||
annexLocationRelative :: Git.Repo -> Key -> FilePath
|
||||
annexLocationRelative r key = Git.dir r ++ "/annex/" ++ (keyFile key)
|
||||
|
||||
{- .git-annex/tmp is used for temp files
|
||||
-}
|
||||
annexTmpLocation :: Git.Repo -> FilePath
|
||||
annexTmpLocation r = (Git.workTree r) ++ "/" ++ Git.dir r ++ "/annex/tmp/"
|
||||
|
||||
{- Converts a key into a filename fragment.
|
||||
-
|
||||
- Escape "/" in the key name, to keep a flat tree of files and avoid
|
||||
|
|
6
TODO
6
TODO
|
@ -1,9 +1,6 @@
|
|||
* bug: cannot "git annex ../foo" (GitRepo.relative is buggy and
|
||||
git-ls-files also refuses w/o --full-name, which would need other changes)
|
||||
|
||||
* bug: git annex add file is silent if file was a symlink and got replaced
|
||||
with a file. The you then git command -a, you'll check in the fil contents..
|
||||
|
||||
* --push/--pull should take a reponame and files, and push those files
|
||||
to that repo; dropping them from the current repo
|
||||
|
||||
|
@ -17,9 +14,6 @@
|
|||
* Support for remote git repositories (ssh:// specifically can be made to
|
||||
work, although the other end probably needs to have git-annex installed..)
|
||||
|
||||
* Copy files atomically, don't leave a partial key on interrupt.
|
||||
(Fix for URL download too..)
|
||||
|
||||
* Find a way to copy a file with a progress bar, while still preserving
|
||||
stat. Easiest way might be to use pv and fix up the permissions etc
|
||||
after?
|
||||
|
|
Loading…
Reference in a new issue