diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-06-02 14:20:38 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-06-02 14:20:38 -0400 |
commit | 72741df36b661ddcee900ab0f0e98357034f7b45 (patch) | |
tree | 758f332e2e39ba93e0b0eee8446cd1e48536987d /CmdLine | |
parent | 7dc6e0c0a087c945ae50d4165076b1123ff31b84 (diff) |
get --incomplete: New option to resume any interrupted downloads.
Diffstat (limited to 'CmdLine')
-rw-r--r-- | CmdLine/GitAnnex/Options.hs | 3 | ||||
-rw-r--r-- | CmdLine/Seek.hs | 31 |
2 files changed, 19 insertions, 15 deletions
diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs index 38fa93090..64435c2e9 100644 --- a/CmdLine/GitAnnex/Options.hs +++ b/CmdLine/GitAnnex/Options.hs @@ -62,6 +62,9 @@ keyOptions = "operate on specified key" ] +incompleteOption :: Option +incompleteOption = flagOption [] "incomplete" "resume previous downloads" + -- Options to match properties of annexed files. annexedMatchingOptions :: [Option] annexedMatchingOptions = concat diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs index 3166ab83d..664c12b62 100644 --- a/CmdLine/Seek.hs +++ b/CmdLine/Seek.hs @@ -27,6 +27,7 @@ import CmdLine.Action import Logs.Location import Logs.Unused import Annex.CatFile +import Annex.Content withFilesInGit :: (FilePath -> CommandStart) -> CommandSeek withFilesInGit a params = seekActions $ prepFiltered a $ @@ -163,42 +164,42 @@ withNothing :: CommandStart -> CommandSeek withNothing a [] = seekActions $ return [a] withNothing _ _ = error "This command takes no parameters." -{- If --all is specified, or in a bare repo, runs an action on all - - known keys. +{- Handles the --all, --unused, --key, and --incomplete options, + - which specify particular keys to run an action on. - - - If --unused is specified, runs an action on all keys found by - - the last git annex unused scan. + - In a bare repo, --all is the default. - - - If --key is specified, operates only on that key. - - - - Otherwise, fall back to a regular CommandSeek action on + - Otherwise falls back to a regular CommandSeek action on - whatever params were passed. -} withKeyOptions :: Bool -> (Key -> CommandStart) -> CommandSeek -> CommandSeek withKeyOptions auto keyop fallbackop params = do bare <- fromRepo Git.repoIsLocalBare allkeys <- Annex.getFlag "all" unused <- Annex.getFlag "unused" + incomplete <- Annex.getFlag "incomplete" specifickey <- Annex.getField "key" when (auto && bare) $ error "Cannot use --auto in a bare repository" - case (allkeys, unused, null params, specifickey) of - (False , False , True , Nothing) + case (allkeys, unused, incomplete, null params, specifickey) of + (False , False , False , True , Nothing) | bare -> go auto loggedKeys | otherwise -> fallbackop params - (False , False , _ , Nothing) -> fallbackop params - (True , False , True , Nothing) -> go auto loggedKeys - (False , True , True , Nothing) -> go auto unusedKeys' - (False , False , True , Just ks) -> case file2key ks of + (False , False , False , _ , Nothing) -> fallbackop params + (True , False , False , True , Nothing) -> go auto loggedKeys + (False , True , False , True , Nothing) -> go auto unusedKeys' + (False , False , True , True , Nothing) -> go auto incompletekeys + (False , False , False , True , Just ks) -> case file2key ks of Nothing -> error "Invalid key" Just k -> go auto $ return [k] - _ -> error "Can only specify one of file names, --all, --unused, or --key" + _ -> error "Can only specify one of file names, --all, --unused, --key, or --incomplete" where - go True _ = error "Cannot use --auto with --all or --unused or --key" + go True _ = error "Cannot use --auto with --all or --unused or --key or --incomplete" go False a = do matcher <- Limit.getMatcher seekActions $ map (process matcher) <$> a process matcher k = ifM (matcher $ MatchingKey k) ( keyop k , return Nothing) + incompletekeys = staleKeysPrune gitAnnexTmpObjectDir True prepFiltered :: (FilePath -> CommandStart) -> Annex [FilePath] -> Annex [CommandStart] prepFiltered a fs = do |