loop chan index
= do req <- atomically $ readTChan chan
case req of
+ RebuildIndex
+ -> do noticeM logger "Rebuilding the H.E. index..."
+ closeDatabase index
+ removeDirectoryRecursive indexDir
+ index' <- openIndex indexDir revFile
+ syncIndex' index' revFile repos mkDraft
+ loop chan index'
+
SyncIndex
- -> syncIndex' index revFile repos mkDraft
+ -> do syncIndex' index revFile repos mkDraft
+ loop chan index
+
SearchIndex cond var
-> do result <- searchIndex index cond
atomically $ putTMVar var result
- loop chan index
+ loop chan index
-- casket を R/W モードで開く。成功したらそのまま返し、失敗したら
return index
Left err
- -> do warningM logger ("Failed to open an H.E. index on "
- ++ indexDir ++ ": " ++ show err)
+ -> do noticeM logger ("Failed to open an H.E. index on "
+ ++ indexDir ++ ": " ++ show err)
indexExists <- doesDirectoryExist indexDir
when indexExists
newRev <- getCurrentRevNum repos
debugM logger ("The repository revision is currently " ++ show newRev)
- when (newRev /= oldRev) (syncIndex'' oldRev newRev)
+ when (oldRev == 0 || newRev /= oldRev)
+ $ syncIndex'' oldRev newRev
return newRev
where
syncIndex'' :: RevNum -> RevNum -> IO ()