+getCurrentRevNum :: Repository -> IO RevNum
+getCurrentRevNum repos
+ = getRepositoryFS repos >>= getYoungestRev
+
+
+startIndexManager :: FilePath -> Repository -> (Page -> IO Document) -> IO (TChan IndexReq)
+startIndexManager lsdir repos mkDraft
+ = do chan <- newTChanIO
+ index <- openIndex indexDir revFile
+ forkIO (loop chan index)
+ return chan
+ where
+ indexDir = lsdir </> "index"
+ revFile = lsdir </> "indexRev"
+
+ loop :: TChan IndexReq -> Database -> IO ()
+ loop chan index
+ = do req <- atomically $ readTChan chan
+ case req of
+ SyncIndex
+ -> syncIndex' index revFile repos mkDraft
+ SearchIndex cond var
+ -> do result <- searchIndex index cond
+ atomically $ putTMVar var result
+ loop chan index