Commits

Sergey Astanin committed 8497b12 Merge

Merged.

  • Participants
  • Parent commits 9d54f22, 1860b85

Comments (0)

Files changed (3)

   Build-depends:
                  haskell98
                , base >= 3 && < 5
+               , mtl
                , filepath
                , directory
                , bytestring
                , HDBC
                , HDBC-sqlite3
                , convertible
-               , LibZip >= 0.0.2 && < 0.1
+               , LibZip >= 0.2 && < 0.3
                , xml
                , hslogger
 
                , HDBC-sqlite3
                , convertible
                , stm
-               , LibZip >= 0.0.2 && < 0.1
+               , LibZip >= 0.2 && < 0.3
                , unix
                , HFuse >= 0.2.1
                , hslogger
 import Control.Applicative ((<$>))
 import Text.Regex.TDFA ((=~))
 
-import Codec.Archive.LibZip
+import Codec.Archive.LibZip.LegacyZeroZero
 
 import System.Log.Logger
 import System.Log.Handler.Syslog
 module Main where
 
 import Control.Monad (forM_)
+import Control.Monad.Trans (liftIO)
 import System.Directory (canonicalizePath)
 import System.Environment (getArgs)
 import IO (stderr, hPutStrLn)
+import Data.Word (Word8)
 
 import qualified System.IO.UTF8 as U
 
   forM_ args $ \arg -> do
     catchZipError $ do
       zipfile <- canonicalizePath arg
-      withZip zipfile [] $ \z -> do
-        files <- getFiles z []
+      withArchive [] zipfile $ do
+        files <- fileNames []
         forM_ files $ \file -> do
-          -- TODO: implement lazy reading in LibZip
-          txt <- readZipFileHead' z file [] fbHeadSize
-          sz <- getFileSize z file []
+          sz <- fileSize [] file
+          txt <- fromFile [] file $ readBytes fbHeadSize
           let info = let i = readBookInfo $ toString txt
                      in  i { archive = zipfile, path = file, size = sz }
-          catchSql (insert file db info)
+          liftIO $ catchSql (insert file db info)
             $ \e -> putErr $ "DB error: " ++ file ++ ": " ++ (seErrorMsg e)
     $ \e -> putErr $ "Archive error: " ++ arg ++ ": " ++ (show e)
   where