From 7f9eb02f5c420d8f9e425310d3982145649dbba1 Mon Sep 17 00:00:00 2001 From: Jose A Ortega Ruiz Date: Sat, 20 Feb 2010 01:23:25 +0100 Subject: Using ByteStrings to more resilient MBox counting Ignore-this: 3fd6e381a8c2810f330131491d03afef darcs-hash:20100220002325-748be-6fdb04d60e7a7e5d8c6fe7cd5af4c5e7c2fd7cf4.gz --- Plugins/MBox.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/MBox.hs b/Plugins/MBox.hs index 8ca0e76..3f7b70c 100644 --- a/Plugins/MBox.hs +++ b/Plugins/MBox.hs @@ -25,7 +25,7 @@ import System.Directory import System.FilePath import System.INotify -import Data.List (isPrefixOf) +import qualified Data.ByteString.Lazy.Char8 as B -- | A list of display names, paths to mbox files and display colours, -- followed by a directory to resolve relative path names (can be "") @@ -63,8 +63,9 @@ showC m n c = countMails :: FilePath -> IO Int countMails f = handle ((\_ -> evaluate 0) :: SomeException -> IO Int) - (do txt <- readFileSafe f - evaluate $! length . filter (isPrefixOf "From ") . lines $ txt) + (do txt <- B.readFile f + evaluate $! length . filter (B.isPrefixOf from) . B.lines $ txt) + where from = B.pack "From " handleNotification :: TVar (FilePath, Int) -> Event -> IO () handleNotification v _ = do -- cgit v1.2.3