remove optimize subcommand; use --auto instead

get, drop: Added --auto option, which decides whether to get/drop content
as needed to work toward the configured numcopies.

The problem with bundling it up in optimize was that I then found I wanted
to run an optmize that did not drop files, only got them. Considered adding
a --only-get switch to it, but that seemed wrong. Instead, let's make
existing subcommands optionally smarter.

Note that the only actual difference between drop and drop --auto is that
the latter does not even try to drop a file if it knows of not enough
copies, and does not print any error messages about files it was unable to
drop.

It might be nice to make get avoid asking git for attributes when not in
auto mode. For now it always asks for attributes.
This commit is contained in:
Joey Hess 2011-09-15 13:30:04 -04:00
parent 81984e60ac
commit 984c9fc052
13 changed files with 92 additions and 78 deletions

View file

@ -29,13 +29,15 @@ seek = [withNumCopies start]
{- Indicates a file's content is not wanted anymore, and should be removed
- if it's safe to do so. -}
start :: CommandStartAttrFile
start (file, numcopies) = isAnnexed file $ \(key, _) -> do
start (file, attr) = isAnnexed file $ \(key, _) -> do
present <- inAnnex key
if present
then do
then autoCopies key (>) numcopies $ do
showStart "drop" file
next $ perform key $ readMaybe numcopies
next $ perform key numcopies
else stop
where
numcopies = readMaybe attr
perform :: Key -> Maybe Int -> CommandPerform
perform key numcopies = do