git-annex/Assistant/Threads/Transferrer.hs

28 lines
758 B
Haskell
Raw Normal View History

2012-07-05 20:34:20 +00:00
{- git-annex assistant data transferrer thread
-
- Copyright 2012 Joey Hess <id@joeyh.name>
2012-07-05 20:34:20 +00:00
-
- Licensed under the GNU AGPL version 3 or higher.
2012-07-05 20:34:20 +00:00
-}
module Assistant.Threads.Transferrer where
import Assistant.Common
2012-07-05 20:34:20 +00:00
import Assistant.TransferQueue
import Assistant.TransferSlots
import Types.Transfer
import Annex.TransferrerPool
import Utility.Batch
2012-07-05 20:34:20 +00:00
{- Dispatches transfers from the queue. -}
transfererThread :: NamedThread
transfererThread = namedThread "Transferrer" $ do
rt <- liftAnnex . mkRunTransferrer
=<< liftIO getBatchCommandMaker
forever $ inTransferSlot rt $
2013-10-03 02:59:07 +00:00
maybe (return Nothing) (uncurry genTransfer)
=<< getNextTransfer notrunning
where
{- Skip transfers that are already running. -}
notrunning = isNothing . startedTime