Sergey Astanin avatar Sergey Astanin committed 8497b12 Merge

Merged.

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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.