scion-browser 0.4.2 → 0.4.3
raw patch · 5 files changed
+21/−17 lines, 5 files
Files
- scion-browser.cabal +1/−1
- src/Scion/PersistentBrowser/Build.hs +3/−3
- src/Scion/PersistentBrowser/Util.hs +6/−2
- src/Scion/PersistentHoogle.hs +7/−4
- src/Server/PersistentCommands.hs +4/−7
scion-browser.cabal view
@@ -1,5 +1,5 @@ name: scion-browser -version: 0.4.2+version: 0.4.3 cabal-version: >= 1.8 build-type: Simple license: BSD3
src/Scion/PersistentBrowser/Build.hs view
@@ -112,9 +112,9 @@ runSQL file f= runResourceT $ runLogging $ withSqliteConn (T.pack file) $ runSqlConn f -- | Updates a database with changes in the installed package base. -updateDatabase :: FilePath -> [InstalledPackageInfo] -> IO () -updateDatabase file pkgInfo = do - hoogleDir <- getHoogleDir file +updateDatabase :: FilePath -> Maybe FilePath -> [InstalledPackageInfo] -> IO () +updateDatabase file msandbox pkgInfo = do + hoogleDir <- getHoogleDir file msandbox runSQL file $ updateDatabase' hoogleDir pkgInfo -- runStderrLoggingT $
src/Scion/PersistentBrowser/Util.hs view
@@ -12,8 +12,12 @@ import System.Directory -- | Get the Hoogle dir from the db file-getHoogleDir :: FilePath -> IO FilePath-getHoogleDir file = do+getHoogleDir :: FilePath -> Maybe FilePath -> IO FilePath+getHoogleDir _ (Just fp) = do+ let hoogleDir = takeDirectory fp </> "hoogle"+ createDirectoryIfMissing True hoogleDir+ return hoogleDir+getHoogleDir file Nothing = do let hoogleDir = takeDirectory file </> "hoogle" createDirectoryIfMissing True hoogleDir return hoogleDir
src/Scion/PersistentHoogle.hs view
@@ -31,7 +31,8 @@ import Scion.PersistentBrowser.FileUtil (withWorkingDirectory) query :: FilePath -> Maybe FilePath -> Maybe FilePath -> String -> SQL [Result] -query hoogleDir msandbox p q = do +query localDB msandbox p q = do + hoogleDir <- liftIO $ getHoogleDir localDB msandbox mpath <- liftIO $ findHoogleBinPath msandbox p case mpath of Nothing -> return [] @@ -51,7 +52,8 @@ return [] downloadData :: FilePath -> Maybe FilePath -> Maybe FilePath -> IO HoogleStatus -downloadData hoogleDir msandbox p = do +downloadData localDB msandbox p = do + hoogleDir <- getHoogleDir localDB msandbox mpath <- findHoogleBinPath msandbox p case mpath of Nothing -> return Missing @@ -65,7 +67,8 @@ _-> Error checkDatabase :: FilePath -> Maybe FilePath -> Maybe FilePath -> IO HoogleStatus -checkDatabase hoogleDir msandbox p = do +checkDatabase localDB msandbox p = do + hoogleDir <- getHoogleDir localDB msandbox mpath <- findHoogleBinPath msandbox p case mpath of Nothing -> return Missing @@ -80,7 +83,7 @@ -- | Init hoogle DB, adding extra files initDatabase :: FilePath -> Maybe FilePath -> Maybe FilePath -> Bool-> IO HoogleStatus initDatabase localDB msandbox p addToDb = do - hoogleDir <- getHoogleDir localDB + hoogleDir <- getHoogleDir localDB msandbox mpath <- findHoogleBinPath msandbox p case mpath of Nothing -> return Missing
src/Server/PersistentCommands.hs view
@@ -95,7 +95,7 @@ createIndexes pkgInfos' <- getPkgInfos msandbox let pkgInfos = concatMap snd pkgInfos' - updateDatabase path pkgInfos + updateDatabase path msandbox pkgInfos if fileExists || rebuild -- If the file already existed or was rebuilt then do modify (\s -> s { localDb = Just path }) lift $ logToStdout "Local database loaded" @@ -127,19 +127,16 @@ do decls <- runDb cdb (getDeclsFromPrefix prefix) return (nubJSON decls, True) executeCommand (HoogleQuery path cdb query msandbox) = do - hoogleDir <- liftIO $ getHoogleDir path extraH <- fmap extraHooglePath get - results <- runDb cdb (\_ -> H.query hoogleDir msandbox extraH query) + results <- runDb cdb (\_ -> H.query path msandbox extraH query) return (nubJSON results, True) executeCommand (HoogleDownloadData path msandbox) = do - hoogleDir <- liftIO $ getHoogleDir path extraH <- fmap extraHooglePath get - ret <- lift $ H.downloadData hoogleDir msandbox extraH + ret <- lift $ H.downloadData path msandbox extraH return (String $ T.pack $ show ret, True) executeCommand (HoogleCheckDatabase path msandbox) = do - hoogleDir <- liftIO $ getHoogleDir path extraH <- fmap extraHooglePath get - ret <- lift $ H.checkDatabase hoogleDir msandbox extraH + ret <- lift $ H.checkDatabase path msandbox extraH return (String $ T.pack $ show ret, True) executeCommand (HoogleInitDatabase path addToDB msandbox) = do extraH <- fmap extraHooglePath get