refactor
This commit is contained in:
parent
4d0223e962
commit
3149a62a35
6 changed files with 13 additions and 16 deletions
|
@ -18,7 +18,6 @@ import Config.NumCopies
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import qualified Option
|
import qualified Option
|
||||||
import Annex.Wanted
|
import Annex.Wanted
|
||||||
import Types.Key
|
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions [fromOption] $ command "drop" paramPaths seek
|
def = [withOptions [fromOption] $ command "drop" paramPaths seek
|
||||||
|
@ -45,12 +44,12 @@ start from file (key, _) = checkDropAuto from file key $ \numcopies ->
|
||||||
|
|
||||||
startLocal :: AssociatedFile -> NumCopies -> Key -> Maybe Remote -> CommandStart
|
startLocal :: AssociatedFile -> NumCopies -> Key -> Maybe Remote -> CommandStart
|
||||||
startLocal afile numcopies key knownpresentremote = stopUnless (inAnnex key) $ do
|
startLocal afile numcopies key knownpresentremote = stopUnless (inAnnex key) $ do
|
||||||
showStart "drop" (fromMaybe (key2file key) afile)
|
showStart' "drop" key afile
|
||||||
next $ performLocal key numcopies knownpresentremote
|
next $ performLocal key numcopies knownpresentremote
|
||||||
|
|
||||||
startRemote :: AssociatedFile -> NumCopies -> Key -> Remote -> CommandStart
|
startRemote :: AssociatedFile -> NumCopies -> Key -> Remote -> CommandStart
|
||||||
startRemote afile numcopies key remote = do
|
startRemote afile numcopies key remote = do
|
||||||
showStart ("drop " ++ Remote.name remote) (fromMaybe (key2file key) afile)
|
showStart' ("drop " ++ Remote.name remote) key afile
|
||||||
next $ performRemote key numcopies remote
|
next $ performRemote key numcopies remote
|
||||||
|
|
||||||
performLocal :: Key -> NumCopies -> Maybe Remote -> CommandPerform
|
performLocal :: Key -> NumCopies -> Maybe Remote -> CommandPerform
|
||||||
|
|
|
@ -12,7 +12,6 @@ import Command
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Logs.Location
|
import Logs.Location
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Types.Key
|
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [noCommit $ command "dropkey" (paramRepeating paramKey) seek
|
def = [noCommit $ command "dropkey" (paramRepeating paramKey) seek
|
||||||
|
@ -25,7 +24,7 @@ start :: Key -> CommandStart
|
||||||
start key = stopUnless (inAnnex key) $ do
|
start key = stopUnless (inAnnex key) $ do
|
||||||
unlessM (Annex.getState Annex.force) $
|
unlessM (Annex.getState Annex.force) $
|
||||||
error "dropkey can cause data loss; use --force if you're sure you want to do this"
|
error "dropkey can cause data loss; use --force if you're sure you want to do this"
|
||||||
showStart "dropkey" (key2file key)
|
showStart' "dropkey" key Nothing
|
||||||
next $ perform key
|
next $ perform key
|
||||||
|
|
||||||
perform :: Key -> CommandPerform
|
perform :: Key -> CommandPerform
|
||||||
|
|
|
@ -16,7 +16,6 @@ import Config.NumCopies
|
||||||
import Annex.Wanted
|
import Annex.Wanted
|
||||||
import GitAnnex.Options
|
import GitAnnex.Options
|
||||||
import qualified Command.Move
|
import qualified Command.Move
|
||||||
import Types.Key
|
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions getOptions $ command "get" paramPaths seek
|
def = [withOptions getOptions $ command "get" paramPaths seek
|
||||||
|
@ -51,7 +50,7 @@ start' expensivecheck from key afile = stopUnless (not <$> inAnnex key) $
|
||||||
go $ Command.Move.fromPerform src False key afile
|
go $ Command.Move.fromPerform src False key afile
|
||||||
where
|
where
|
||||||
go a = do
|
go a = do
|
||||||
showStart "get" (fromMaybe (key2file key) afile)
|
showStart' "get" key afile
|
||||||
next a
|
next a
|
||||||
|
|
||||||
perform :: Key -> AssociatedFile -> CommandPerform
|
perform :: Key -> AssociatedFile -> CommandPerform
|
||||||
|
|
|
@ -17,7 +17,6 @@ import Annex.UUID
|
||||||
import Logs.Presence
|
import Logs.Presence
|
||||||
import Logs.Transfer
|
import Logs.Transfer
|
||||||
import GitAnnex.Options
|
import GitAnnex.Options
|
||||||
import Types.Key
|
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions moveOptions $ command "move" paramPaths seek
|
def = [withOptions moveOptions $ command "move" paramPaths seek
|
||||||
|
@ -54,10 +53,7 @@ start' to from move afile key = do
|
||||||
"--auto is not supported for move"
|
"--auto is not supported for move"
|
||||||
|
|
||||||
showMoveAction :: Bool -> Key -> AssociatedFile -> Annex ()
|
showMoveAction :: Bool -> Key -> AssociatedFile -> Annex ()
|
||||||
showMoveAction True _ (Just file) = showStart "move" file
|
showMoveAction move = showStart' (if move then "move" else "copy")
|
||||||
showMoveAction False _ (Just file) = showStart "copy" file
|
|
||||||
showMoveAction True key Nothing = showStart "move" (key2file key)
|
|
||||||
showMoveAction False key Nothing = showStart "copy" (key2file key)
|
|
||||||
|
|
||||||
{- Moves (or copies) the content of an annexed file to a remote.
|
{- Moves (or copies) the content of an annexed file to a remote.
|
||||||
-
|
-
|
||||||
|
|
|
@ -14,7 +14,6 @@ import Command
|
||||||
import Remote
|
import Remote
|
||||||
import Logs.Trust
|
import Logs.Trust
|
||||||
import GitAnnex.Options
|
import GitAnnex.Options
|
||||||
import Types.Key
|
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [noCommit $ withOptions (jsonOption : keyOptions) $
|
def = [noCommit $ withOptions (jsonOption : keyOptions) $
|
||||||
|
@ -37,7 +36,7 @@ startKeys remotemap key = start' remotemap key Nothing
|
||||||
|
|
||||||
start' :: M.Map UUID Remote -> Key -> AssociatedFile -> CommandStart
|
start' :: M.Map UUID Remote -> Key -> AssociatedFile -> CommandStart
|
||||||
start' remotemap key afile = do
|
start' remotemap key afile = do
|
||||||
showStart "whereis" (fromMaybe (key2file key) afile)
|
showStart' "whereis" key afile
|
||||||
next $ perform remotemap key
|
next $ perform remotemap key
|
||||||
|
|
||||||
perform :: M.Map UUID Remote -> Key -> CommandPerform
|
perform :: M.Map UUID Remote -> Key -> CommandPerform
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{- git-annex output messages
|
{- git-annex output messages
|
||||||
-
|
-
|
||||||
- Copyright 2010-2011 Joey Hess <joey@kitenet.net>
|
- Copyright 2010-2014 Joey Hess <joey@kitenet.net>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Messages (
|
module Messages (
|
||||||
showStart,
|
showStart,
|
||||||
|
showStart',
|
||||||
showNote,
|
showNote,
|
||||||
showAction,
|
showAction,
|
||||||
showProgress,
|
showProgress,
|
||||||
|
@ -54,10 +55,14 @@ import Types.Key
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Utility.Metered
|
import Utility.Metered
|
||||||
|
|
||||||
showStart :: String -> String -> Annex ()
|
showStart :: String -> FilePath -> Annex ()
|
||||||
showStart command file = handle (JSON.start command $ Just file) $
|
showStart command file = handle (JSON.start command $ Just file) $
|
||||||
flushed $ putStr $ command ++ " " ++ file ++ " "
|
flushed $ putStr $ command ++ " " ++ file ++ " "
|
||||||
|
|
||||||
|
showStart' :: String -> Key -> Maybe FilePath -> Annex ()
|
||||||
|
showStart' command key afile = showStart command $
|
||||||
|
fromMaybe (key2file key) afile
|
||||||
|
|
||||||
showNote :: String -> Annex ()
|
showNote :: String -> Annex ()
|
||||||
showNote s = handle (JSON.note s) $
|
showNote s = handle (JSON.note s) $
|
||||||
flushed $ putStr $ "(" ++ s ++ ") "
|
flushed $ putStr $ "(" ++ s ++ ") "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue