numcopies cleanup, part 2

This includes several bug fixes.
This commit is contained in:
Joey Hess 2014-01-21 17:08:49 -04:00
parent b40df4f0d0
commit 0ef282a116
11 changed files with 104 additions and 77 deletions

View file

@ -28,17 +28,15 @@ seek ps = do
to <- getOptionField toOption Remote.byNameWithUUID
from <- getOptionField fromOption Remote.byNameWithUUID
withKeyOptions
(startKey Nothing to from Nothing)
(startKey to from Nothing)
(withFilesInGit $ whenAnnexed $ start to from)
ps
start :: Maybe Remote -> Maybe Remote -> FilePath -> (Key, Backend) -> CommandStart
start to from file (key, _backend) = do
numcopies <- getFileNumCopies file
startKey numcopies to from (Just file) key
start to from file (key, _backend) = startKey to from (Just file) key
startKey :: Maybe NumCopies -> Maybe Remote -> Maybe Remote -> Maybe FilePath -> Key -> CommandStart
startKey numcopies to from afile key = do
startKey :: Maybe Remote -> Maybe Remote -> Maybe FilePath -> Key -> CommandStart
startKey to from afile key = do
noAuto
case (from, to) of
(Nothing, Nothing) -> error "specify either --from or --to"
@ -50,7 +48,9 @@ startKey numcopies to from afile key = do
error "--auto is not supported for mirror"
mirrorto r = ifM (inAnnex key)
( Command.Move.toStart r False afile key
, Command.Drop.startRemote afile numcopies key r
, do
numcopies <- getnumcopies
Command.Drop.startRemote afile numcopies key r
)
mirrorfrom r = do
haskey <- Remote.hasKey r key
@ -58,6 +58,9 @@ startKey numcopies to from afile key = do
Left _ -> stop
Right True -> Command.Get.start' (return True) Nothing key afile
Right False -> ifM (inAnnex key)
( Command.Drop.startLocal afile numcopies key Nothing
( do
numcopies <- getnumcopies
Command.Drop.startLocal afile numcopies key Nothing
, stop
)
getnumcopies = maybe getNumCopies getFileNumCopies afile