gdritter repos tansu / 94d2292
made filesystem backend actually detect the lack of a key Getty Ritter 8 years ago
1 changed file(s) with 5 addition(s) and 2 deletion(s). Collapse all Expand all
44 import Data.ByteString.Base64
55 import qualified Data.ByteString.Char8 as BS
66 import Database.Tansu.Internal (Database(..))
7 import System.Directory (createDirectoryIfMissing)
7 import System.Directory (createDirectoryIfMissing, doesFileExist)
88 import System.FilePath.Posix ((</>))
99
1010 filePathSet :: FilePath -> ByteString -> ByteString -> IO ()
1515 filePathGet :: FilePath -> ByteString -> IO (Maybe ByteString)
1616 filePathGet path key = do
1717 let keyPath = path </> BS.unpack (encode key)
18 fmap Just $ BS.readFile keyPath
18 exists <- doesFileExist keyPath
19 if exists
20 then Just `fmap` BS.readFile keyPath
21 else return Nothing
1922
2023 withFilesystemDb :: FilePath -> (Database -> IO a) -> IO a
2124 withFilesystemDb path comp = do