diff options
author | Joey Hess <joey@kitenet.net> | 2013-03-18 20:34:56 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-03-18 20:40:24 -0400 |
commit | 9acd2ee80f357d34eee7335f775b47bec87f4aed (patch) | |
tree | 929d65ca08975e520e90b8fe89ffa4d9dafee46a /Assistant | |
parent | f4bb9f0168e8318f78069406b98b3fca10839242 (diff) |
optimisation for transfers to drives that are not plugged in
Rather than forking a git-annex transferkey only to have it fail,
just immediately record the failed transfer (so when the drive is plugged
in, the scan will retry it).
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/Threads/Transferrer.hs | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Assistant/Threads/Transferrer.hs b/Assistant/Threads/Transferrer.hs index 63306831f..2c487657a 100644 --- a/Assistant/Threads/Transferrer.hs +++ b/Assistant/Threads/Transferrer.hs @@ -18,6 +18,8 @@ import Logs.Transfer import Logs.Location import Annex.Content import qualified Remote +import qualified Types.Remote as Remote +import qualified Git import Types.Key import Locations.UserConfig import Assistant.Threads.TransferWatcher @@ -44,18 +46,24 @@ startTransfer -> TransferInfo -> Assistant (Maybe (Transfer, TransferInfo, Assistant ())) startTransfer program t info = case (transferRemote info, associatedFile info) of - (Just remote, Just file) -> ifM (liftAnnex $ shouldTransfer t info) - ( do - debug [ "Transferring:" , describeTransfer t info ] - notifyTransfer - return $ Just (t, info, transferprocess remote file) - , do - debug [ "Skipping unnecessary transfer:", - describeTransfer t info ] + (Just remote, Just file) + | Git.repoIsLocalUnknown (Remote.repo remote) -> do + -- optimisation for removable drives not plugged in + liftAnnex $ recordFailedTransfer t info void $ removeTransfer t - finishedTransfer t (Just info) return Nothing - ) + | otherwise -> ifM (liftAnnex $ shouldTransfer t info) + ( do + debug [ "Transferring:" , describeTransfer t info ] + notifyTransfer + return $ Just (t, info, transferprocess remote file) + , do + debug [ "Skipping unnecessary transfer:", + describeTransfer t info ] + void $ removeTransfer t + finishedTransfer t (Just info) + return Nothing + ) _ -> return Nothing where direction = transferDirection t |