packages feed

json-state 0.1.0.0 → 0.1.0.1

raw patch · 4 files changed

+50/−10 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog view
@@ -1,7 +1,7 @@ The changes are recorded by the version control system, Darcs. To see a log quickly from the terminal, run: -  $ darcs changes --repo http://dev.rel4tion.org/fr33domlover/json-state+  $ darcs changes --repo http://hub.darcs.net/fr33domlover/json-state  There is also a web interface at <http://dev.rel4tion.org> which, among other things, can display the history log.@@ -9,7 +9,7 @@ To see the log in a local clone, first get a copy of the repository if you haven't yet: -  $ darcs get http://dev.rel4tion.org/fr33domlover/json-state+  $ darcs get http://hub.darcs.net/fr33domlover/json-state  Then move into the newly created directory and run darcs: 
NEWS view
@@ -3,6 +3,30 @@   +json-state 0.1.0.1 -- (2015-12-17)+==================================++General, build and documentation changes:++* (None)++New APIs, features and enhancements:++* (None)++Bug fixes:++* Catch exceptions in save actions. Otherwise, an exception thrown causes the+  saver thread to silently die.++Dependency changes:++* (None)+++++ json-state 0.1.0.0 -- (2015-09-17) ================================== 
json-state.cabal view
@@ -1,5 +1,5 @@ name:                json-state-version:             0.1.0.0+version:             0.1.0.1 synopsis:            Keep program state in JSON files. description:   If your program manages simple state data not shared with other programs,@@ -20,7 +20,7 @@  source-repository head   type:                darcs-  location:            http://dev.rel4tion.org/fr33domlover/json-state+  location:            http://hub.darcs.net/fr33domlover/json-state  library   exposed-modules:     Data.JsonState
src/Data/JsonState.hs view
@@ -48,7 +48,8 @@ where  import Control.Debounce (mkDebounce)-import Control.Monad (liftM, when)+import Control.Exception+import Control.Monad (liftM, void, when) import Data.Aeson (FromJSON, ToJSON, eitherDecode) import Data.Aeson.Encode.Pretty (encodePretty) import Data.Time.Units (TimeUnit)@@ -57,6 +58,9 @@  import qualified Data.ByteString.Lazy as B +tryAny :: IO a -> IO (Either SomeException a)+tryAny = try+ -- | Try to load state from a file. -- -- If an error occurs, 'Left' a pair is returned. The boolean indicates whether@@ -73,7 +77,13 @@     return $ pairOrStr >>= either (Left . (,) True) Right . eitherDecode  saveAction :: ToJSON s => FilePath -> s -> IO ()-saveAction file s = B.writeFile file $ encodePretty s+saveAction file s = do+    res <- tryAny $ B.writeFile file $ encodePretty s+    case res of+        Left err -> void $ tryAny $ do+            putStrLn "json-state saveAction caught exception:"+            print err+        Right () -> return ()  -- | Prepare a save action which writes state into a JSON file. This action -- defers the work to a separate dedicated thread, and ensures the file isn't@@ -93,10 +103,16 @@  saveActionVC :: ToJSON s => FilePath -> Config -> String -> (s, Bool) -> IO () saveActionVC file cfg msg (s, git) = do-    saveAction (configCwd cfg ++ '/' : file) s-    when git $ runGit cfg $ do-        add [file]-        commit [] "json-state" "json@state" msg []+    res <- tryAny $ do+        saveAction (configCwd cfg ++ '/' : file) s+        when git $ runGit cfg $ do+            add [file]+            commit [] "json-state" "json@state" msg []+    case res of+        Left err -> void $ tryAny $ do+            putStrLn "json-state saveActionVC caught exception:"+            print err+        Right () -> return ()  -- | Like 'mkSaveState', but also takes a repository path. Creates a Git -- repository there if there isn't yet. Two save actions are returned. The