List the firefox places.sqlite

This commit is contained in:
Mats Rauhala 2021-01-03 09:00:40 +02:00
parent a1e67c6387
commit 25ecac21fa
3 changed files with 60 additions and 7 deletions

View File

@ -40,6 +40,7 @@ library
, Operations.Insert , Operations.Insert
, Operations.List , Operations.List
, Operations.Query , Operations.Query
, Operations.Import.Firefox
, Operations , Operations
, Data.Environment , Data.Environment
, Data.Buuka , Data.Buuka
@ -61,6 +62,9 @@ library
, lens , lens
, hashable , hashable
, regex-tdfa , regex-tdfa
, sqlite-simple
, conduit
, conduit-extra
hs-source-dirs: src hs-source-dirs: src
executable buuka executable buuka

View File

@ -1,8 +1,9 @@
{ mkDerivation, aeson, base, bytestring, containers { mkDerivation, aeson, base, bytestring, conduit, conduit-extra
, deriving-compat, exceptions, filepath, hashable, hashids , containers, deriving-compat, exceptions, filepath, hashable
, hedgehog, hedgehog-corpus, lens, mtl, optparse-applicative , hashids, hedgehog, hedgehog-corpus, lens, mtl
, regex-tdfa, stdenv, tasty, tasty-hedgehog, tasty-hunit, text , optparse-applicative, regex-tdfa, sqlite-simple, stdenv, tasty
, transformers, unliftio, vector, yaml , tasty-hedgehog, tasty-hunit, text, transformers, unliftio, vector
, yaml
}: }:
mkDerivation { mkDerivation {
pname = "buuka"; pname = "buuka";
@ -11,8 +12,9 @@ mkDerivation {
isLibrary = true; isLibrary = true;
isExecutable = true; isExecutable = true;
libraryHaskellDepends = [ libraryHaskellDepends = [
aeson base bytestring containers exceptions filepath hashable aeson base bytestring conduit conduit-extra containers exceptions
hashids lens mtl regex-tdfa text transformers unliftio vector yaml filepath hashable hashids lens mtl regex-tdfa sqlite-simple text
transformers unliftio vector yaml
]; ];
executableHaskellDepends = [ base optparse-applicative unliftio ]; executableHaskellDepends = [ base optparse-applicative unliftio ];
testHaskellDepends = [ testHaskellDepends = [

View File

@ -0,0 +1,47 @@
{-|
Module : Operations.Import.Firefox
Description : Imports from firefox
Copyright : (c) Mats Rauhala, 2020
License : BSD-3-Clause
Maintainer : mats.rauhala@iki.fi
Stability : experimental
Portability : POSIX
Imports from firefox. Firefox needs to be closed when doing the import
-}
module Operations.Import.Firefox where
import Conduit
import qualified Data.Conduit.Combinators as C
import System.FilePath
(takeFileName, (</>))
import Control.Exception
(Exception)
import System.Environment
(lookupEnv)
import GHC.Stack
-- select p.title, p.url from moz_bookmarks b join moz_places p on b.fk = p.id
--
-- select keyword from moz_keywords where place_id = ?
newtype ImportException
= HomeNotFound CallStack
deriving stock (Show)
deriving anyclass (Exception)
stores
:: MonadResource m
=> MonadThrow m
=> MonadIO m
=> HasCallStack
=> ConduitT i FilePath m ()
stores = liftIO (lookupEnv "HOME") >>= maybe (throwM (HomeNotFound callStack)) listStores
where
listStores home =
sourceDirectoryDeep False (home </> ".mozilla/firefox")
.| C.filter (\p -> takeFileName p == "places.sqlite")