summaryrefslogtreecommitdiff
path: root/Assistant/Threads/TransferScanner.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-22 23:16:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-22 23:16:56 -0400
commit522f568450a005ae81b24f63bb37e75320b51219 (patch)
tree93c292de024b4e1c6e8bbefd4aee9614c6ab0afc /Assistant/Threads/TransferScanner.hs
parent26e4e65307436e4cc9a2db448141652b79d0f582 (diff)
add TransferScanner thread
Efficiently finding transfers that need to be done to get two repos back in sync seems like an interesting problem.
Diffstat (limited to 'Assistant/Threads/TransferScanner.hs')
-rw-r--r--Assistant/Threads/TransferScanner.hs34
1 files changed, 34 insertions, 0 deletions
diff --git a/Assistant/Threads/TransferScanner.hs b/Assistant/Threads/TransferScanner.hs
new file mode 100644
index 000000000..0a40f7ead
--- /dev/null
+++ b/Assistant/Threads/TransferScanner.hs
@@ -0,0 +1,34 @@
+{- git-annex assistant thread to scan remotes to find needed transfers
+ -
+ - Copyright 2012 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Assistant.Threads.TransferScanner where
+
+import Assistant.Common
+import Assistant.ScanRemotes
+import Assistant.TransferQueue
+import Assistant.ThreadedMonad
+import Logs.Transfer
+import Types.Remote
+import Utility.ThreadScheduler
+
+thisThread :: ThreadName
+thisThread = "TransferScanner"
+
+{- This thread scans remotes, to find transfers that need to be made to
+ - keep their data in sync. The transfers are queued with lot priority. -}
+transferScannerThread :: ThreadState -> ScanRemoteMap -> TransferQueue -> IO ()
+transferScannerThread st scanremotes transferqueue = do
+ runEvery (Seconds 2) $ do
+ r <- getScanRemote scanremotes
+ needtransfer <- scan st r
+ forM_ needtransfer $ \(f, t) ->
+ queueLaterTransfer transferqueue f t
+
+scan :: ThreadState -> Remote -> IO [(AssociatedFile, Transfer)]
+scan st r = do
+ debug thisThread ["scanning", show r]
+ return [] -- TODO