diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-02-13 17:30:28 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-02-13 17:39:16 -0400 |
commit | ab15aba7e4eb7fcc6d1e1423622a0e1bc04c567e (patch) | |
tree | 859c5098a50217580cb803dd99e166ad76b9e814 /Database/Handle.hs | |
parent | 6e5180c8d52cabffff00fda0682b6cb280e95b36 (diff) |
Work around sqlite's incorrect handling of umask when creating databases.
Refactored some common code into initDb.
This only deals with the problem when creating new databases. If a repo
got bad permissions into it, it's up to the user to deal with it.
This commit was sponsored by Ole-Morten Duesund on Patreon.
Diffstat (limited to 'Database/Handle.hs')
-rw-r--r-- | Database/Handle.hs | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/Database/Handle.hs b/Database/Handle.hs index d84ce5b62..7827be749 100644 --- a/Database/Handle.hs +++ b/Database/Handle.hs @@ -9,7 +9,6 @@ module Database.Handle ( DbHandle, - initDb, openDb, TableName, queryDb, @@ -38,26 +37,6 @@ import System.IO - the database. It has a MVar which Jobs are submitted to. -} data DbHandle = DbHandle (Async ()) (MVar Job) -{- Ensures that the database is initialized. Pass the migration action for - - the database. - - - - The database is initialized using WAL mode, to prevent readers - - from blocking writers, and prevent a writer from blocking readers. - -} -initDb :: FilePath -> SqlPersistM () -> IO () -initDb f migration = do - let db = T.pack f - enableWAL db - runSqlite db migration - -enableWAL :: T.Text -> IO () -enableWAL db = do - conn <- Sqlite.open db - stmt <- Sqlite.prepare conn (T.pack "PRAGMA journal_mode=WAL;") - void $ Sqlite.step stmt - void $ Sqlite.finalize stmt - Sqlite.close conn - {- Name of a table that should exist once the database is initialized. -} type TableName = String |