Merge branch 'master' into assistant
This commit is contained in:
commit
7625319c2c
35 changed files with 526 additions and 93 deletions
|
@ -94,7 +94,7 @@ performRemote key file backend numcopies remote =
|
|||
( return True
|
||||
, ifM (Annex.getState Annex.fast)
|
||||
( return False
|
||||
, Remote.retrieveKeyFile remote key tmp
|
||||
, Remote.retrieveKeyFile remote key Nothing tmp
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import Command
|
|||
import qualified Remote
|
||||
import Annex.Content
|
||||
import qualified Command.Move
|
||||
import Logs.Transfer
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions [Command.Move.fromOption] $ command "get" paramPaths seek
|
||||
|
@ -25,24 +26,24 @@ start :: Maybe Remote -> FilePath -> (Key, Backend) -> CommandStart
|
|||
start from file (key, _) = stopUnless (not <$> inAnnex key) $
|
||||
autoCopies file key (<) $ \_numcopies ->
|
||||
case from of
|
||||
Nothing -> go $ perform key
|
||||
Nothing -> go $ perform key file
|
||||
Just src ->
|
||||
-- get --from = copy --from
|
||||
stopUnless (Command.Move.fromOk src key) $
|
||||
go $ Command.Move.fromPerform src False key
|
||||
go $ Command.Move.fromPerform src False key file
|
||||
where
|
||||
go a = do
|
||||
showStart "get" file
|
||||
next a
|
||||
next a
|
||||
|
||||
perform :: Key -> CommandPerform
|
||||
perform key = stopUnless (getViaTmp key $ getKeyFile key) $
|
||||
perform :: Key -> FilePath -> CommandPerform
|
||||
perform key file = stopUnless (getViaTmp key $ getKeyFile key file) $
|
||||
next $ return True -- no cleanup needed
|
||||
|
||||
{- Try to find a copy of the file in one of the remotes,
|
||||
- and copy it to here. -}
|
||||
getKeyFile :: Key -> FilePath -> Annex Bool
|
||||
getKeyFile key file = dispatch =<< Remote.keyPossibilities key
|
||||
getKeyFile :: Key -> FilePath -> FilePath -> Annex Bool
|
||||
getKeyFile key file dest = dispatch =<< Remote.keyPossibilities key
|
||||
where
|
||||
dispatch [] = do
|
||||
showNote "not available"
|
||||
|
@ -64,7 +65,7 @@ getKeyFile key file = dispatch =<< Remote.keyPossibilities key
|
|||
| Remote.hasKeyCheap r =
|
||||
either (const False) id <$> Remote.hasKey r key
|
||||
| otherwise = return True
|
||||
docopy r continue = do
|
||||
docopy r continue = download (Remote.uuid r) key (Just file) $ do
|
||||
showAction $ "from " ++ Remote.name r
|
||||
ifM (Remote.retrieveKeyFile r key file)
|
||||
ifM (Remote.retrieveKeyFile r key (Just file) dest)
|
||||
( return True , continue)
|
||||
|
|
|
@ -16,6 +16,7 @@ import qualified Remote
|
|||
import Annex.UUID
|
||||
import qualified Option
|
||||
import Logs.Presence
|
||||
import Logs.Transfer
|
||||
|
||||
def :: [Command]
|
||||
def = [withOptions options $ command "move" paramPaths seek
|
||||
|
@ -68,9 +69,9 @@ toStart dest move file key = do
|
|||
then stop -- not here, so nothing to do
|
||||
else do
|
||||
showMoveAction move file
|
||||
next $ toPerform dest move key
|
||||
toPerform :: Remote -> Bool -> Key -> CommandPerform
|
||||
toPerform dest move key = moveLock move key $ do
|
||||
next $ toPerform dest move key file
|
||||
toPerform :: Remote -> Bool -> Key -> FilePath -> CommandPerform
|
||||
toPerform dest move key file = moveLock move key $ do
|
||||
-- Checking the remote is expensive, so not done in the start step.
|
||||
-- In fast mode, location tracking is assumed to be correct,
|
||||
-- and an explicit check is not done, when copying. When moving,
|
||||
|
@ -88,7 +89,8 @@ toPerform dest move key = moveLock move key $ do
|
|||
stop
|
||||
Right False -> do
|
||||
showAction $ "to " ++ Remote.name dest
|
||||
ok <- Remote.storeKey dest key
|
||||
ok <- upload (Remote.uuid dest) key (Just file) $
|
||||
Remote.storeKey dest key (Just file)
|
||||
if ok
|
||||
then finish
|
||||
else do
|
||||
|
@ -118,7 +120,7 @@ fromStart src move file key
|
|||
where
|
||||
go = stopUnless (fromOk src key) $ do
|
||||
showMoveAction move file
|
||||
next $ fromPerform src move key
|
||||
next $ fromPerform src move key file
|
||||
fromOk :: Remote -> Key -> Annex Bool
|
||||
fromOk src key
|
||||
| Remote.hasKeyCheap src =
|
||||
|
@ -129,13 +131,14 @@ fromOk src key
|
|||
u <- getUUID
|
||||
remotes <- Remote.keyPossibilities key
|
||||
return $ u /= Remote.uuid src && elem src remotes
|
||||
fromPerform :: Remote -> Bool -> Key -> CommandPerform
|
||||
fromPerform src move key = moveLock move key $
|
||||
fromPerform :: Remote -> Bool -> Key -> FilePath -> CommandPerform
|
||||
fromPerform src move key file = moveLock move key $
|
||||
ifM (inAnnex key)
|
||||
( handle move True
|
||||
, do
|
||||
, download (Remote.uuid src) key (Just file) $ do
|
||||
showAction $ "from " ++ Remote.name src
|
||||
ok <- getViaTmp key $ Remote.retrieveKeyFile src key
|
||||
ok <- getViaTmp key $
|
||||
Remote.retrieveKeyFile src key (Just file)
|
||||
handle move ok
|
||||
)
|
||||
where
|
||||
|
|
|
@ -31,6 +31,7 @@ import Logs.Trust
|
|||
import Remote
|
||||
import Config
|
||||
import Utility.Percentage
|
||||
import Logs.Transfer
|
||||
|
||||
-- a named computation that produces a statistic
|
||||
type Stat = StatState (Maybe (String, StatState String))
|
||||
|
@ -70,6 +71,7 @@ fast_stats =
|
|||
, remote_list SemiTrusted "semitrusted"
|
||||
, remote_list UnTrusted "untrusted"
|
||||
, remote_list DeadTrusted "dead"
|
||||
, transfer_list
|
||||
, disk_size
|
||||
]
|
||||
slow_stats :: [Stat]
|
||||
|
@ -170,6 +172,24 @@ bloom_info = stat "bloom filter size" $ json id $ do
|
|||
|
||||
return $ size ++ note
|
||||
|
||||
transfer_list :: Stat
|
||||
transfer_list = stat "transfers in progress" $ nojson $ lift $ do
|
||||
uuidmap <- Remote.remoteMap id
|
||||
ts <- getTransfers
|
||||
if null ts
|
||||
then return "none"
|
||||
else return $ pp uuidmap "" $ sort ts
|
||||
where
|
||||
pp _ c [] = c
|
||||
pp uuidmap c ((t, i):xs) = "\n\t" ++ line uuidmap t i ++ pp uuidmap c xs
|
||||
line uuidmap t i = unwords
|
||||
[ show (transferDirection t) ++ "ing"
|
||||
, fromMaybe (show $ transferKey t) (associatedFile i)
|
||||
, if transferDirection t == Upload then "to" else "from"
|
||||
, maybe (fromUUID $ transferRemote t) Remote.name $
|
||||
M.lookup (transferRemote t) uuidmap
|
||||
]
|
||||
|
||||
disk_size :: Stat
|
||||
disk_size = stat "available local disk space" $ json id $ lift $
|
||||
calcfree
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue