Permalink
Browse files

Added sketch of filesystem database.

  • Loading branch information...
1 parent c5c9b04 commit 7f724678add06798ec24fef97561184eb11ece18 @luqui committed Nov 17, 2008
Showing with 23 additions and 17 deletions.
  1. +20 −0 udon-shell/UdonShell/FSDB.hs
  2. +1 −1 udon-shell/UdonShell/FST.hs
  3. +0 −16 udon/Udon/MapDatabase.hs
  4. +2 −0 udon/udon.cabal
@@ -0,0 +1,20 @@
+module UdonShell.FSDB (fsdb) where
+
+import Udon.DBAPI
+import qualified UdonShell.FST as FST
+
+hashToPath h = [showHash h]
+
+fsdb :: Database FST.FST
+fsdb = Database {
+ fetch = \h -> do
+ let file = hashToPath h
+ exists <- FST.checkFile file
+ return $ if exists
+ then Just $ FST.readFile file
+ else Nothing,
+ store = \h blob -> FST.newFile (hashToPath h) blob,
+ export = \h -> return ()
+ }
+
+
@@ -1,6 +1,6 @@
module UdonShell.FST
( FST, makeFSTDir, runFST
- , newFile, checkFile, readFile, deleteFile
+ , Path, newFile, checkFile, readFile, deleteFile
)
where
View
@@ -1,16 +0,0 @@
-module Udon.MapDatabase where
-
-import Udon.Hash
-import Udon.Database
-import qualified Data.Map as Map
-import Control.Monad.State
-import Control.Monad
-
-mapDatabase :: (MonadState (Map.Map Hash Blob) m) => Database m
-mapDatabase = Database {
- fetch = \hash -> liftM (liftM return . Map.lookup hash) get,
- store = \hash blob -> modify (Map.insert hash blob),
- export = \_ -> return ()
- }
-
-
View
@@ -12,4 +12,6 @@ Maintainer: lrpalmer@gmail.com
Build-Type: Simple
Build-Depends: base, binary, mtl, containers, bytestring, dataenc, Crypto
Exposed-Modules: Udon.API, Udon.DBAPI, Udon.DescCombinators
+Other-Modules: Udon.Chunk, Udon.DataDesc, Udon.Database, Udon.DescInstances,
+ Udon.DynRef, Udon.External, Udon.Hash, Udon.Request
Extensions:

0 comments on commit 7f72467

Please sign in to comment.