]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Storage/Repos.hs
Fixing build breakage...
[Rakka.git] / Rakka / Storage / Repos.hs
index 8f49cbe4ad8c512004be6c52574276ef0427172d..ae4ce706d9f1a04f014b5e94d813e0476e71797f 100644 (file)
@@ -1,3 +1,4 @@
+-- -*- coding: utf-8 -*-
 module Rakka.Storage.Repos
     ( findAllPagesInRevision
     , getDirContentsInRevision
@@ -9,9 +10,6 @@ module Rakka.Storage.Repos
     , putAttachmentIntoRepository
     )
     where
-
-import           Codec.Binary.UTF8.String
-import           Control.Exception
 import           Control.Monad
 import           Data.List
 import qualified Data.Map as M
@@ -19,13 +17,12 @@ import           Data.Maybe
 import           Data.Set (Set)
 import qualified Data.Set as S hiding (Set)
 import           Data.Time
+import qualified Data.Time.W3C as W3C
 import           Network.HTTP.Lucu hiding (redirect)
 import           Rakka.Attachment
 import           Rakka.Page
 import           Rakka.SystemConfig
 import           Rakka.Utils
-import           Rakka.W3CDateTime
-import           Subversion.Error
 import           Subversion.FileSystem
 import           Subversion.FileSystem.DirEntry
 import           Subversion.FileSystem.Revision
@@ -164,7 +161,7 @@ loadPageInRepository repos name rev
                               $ fmap chomp (lookup "svn:mime-type" props)
 
                lastMod <- unsafeIOToFS $
-                          liftM (fromJust . parseW3CDateTime . chomp . fromJust)
+                          liftM (fromJust . W3C.parse . chomp . fromJust)
                                 (getRevisionProp' fs pageRev "svn:date")
 
                return Entity {
@@ -199,7 +196,7 @@ loadPageInRepository repos name rev
                    dest    = chomp $ decodeString content
 
                lastMod <- unsafeIOToFS $
-                          liftM (fromJust . parseW3CDateTime . chomp . fromJust)
+                          liftM (fromJust . W3C.parse . chomp . fromJust)
                                 (getRevisionProp' fs pageRev "svn:date")
 
                isLocked <- liftM isJust (getNodeProp path "rakka:isLocked")
@@ -216,8 +213,7 @@ loadPageInRepository repos name rev
 
 putPageIntoRepository :: Repository -> Maybe String -> Page -> IO StatusCode
 putPageIntoRepository repos userID page
-    = filterSvnError $
-      do let name   = pageName page
+    = do let name   = pageName page
              author = fromMaybe "[Rakka]" userID
          case pageUpdateInfo page of
            Just ui
@@ -357,8 +353,7 @@ createParentDirectories path
 
 deletePageFromRepository :: Repository -> Maybe String -> PageName -> IO StatusCode
 deletePageFromRepository repos userID name
-    = filterSvnError $
-      do let pagePath       = mkPagePath name
+    = do let pagePath       = mkPagePath name
              attachmentPath = mkAttachmentDirPath name
          fs     <- getRepositoryFS repos
          rev    <- getYoungestRev fs
@@ -378,7 +373,7 @@ deletePageFromRepository repos userID name
                           else
                             return NotFound
          when (status == NoContent)
-             $ do doReposTxn repos
+             $ ( (doReposTxn repos
                              rev
                              "[Rakka]"
                              (Just "Automatic commit by Rakka for page deleting")
@@ -388,8 +383,8 @@ deletePageFromRepository repos userID name
                                   attachmentExists <- isDirectory attachmentPath
                                   when attachmentExists
                                       $ do deleteEntry attachmentPath
-                                           deleteEmptyParentDirectories attachmentPath
-                  return ()
+                                           deleteEmptyParentDirectories attachmentPath)
+                 >> return () )
          return status
 
 
@@ -436,8 +431,7 @@ putAttachmentIntoRepository :: Attachment a =>
                             -> a
                             -> IO StatusCode
 putAttachmentIntoRepository repos userID oldRev pName aName attachment
-    = filterSvnError $
-      do let author = fromMaybe "[Rakka]" userID
+    = do let author = fromMaybe "[Rakka]" userID
              path   = mkAttachmentPath pName aName
          fs      <- getRepositoryFS repos
          oldRev' <- case oldRev of
@@ -452,18 +446,7 @@ putAttachmentIntoRepository repos userID oldRev pName aName attachment
                      unless exists
                          $ do createParentDirectories path
                               makeFile path
-                     applyText path Nothing (serializeToString attachment)
+                     applyText path Nothing (encodeString $ serializeToString attachment)
          case ret of
            Left  _ -> return Conflict
            Right _ -> return NoContent
-
-
-filterSvnError :: IO a -> IO a
-filterSvnError f = catchDyn f rethrow
-    where
-      rethrow :: SvnError -> IO a
-      rethrow err
-          = let code = svnErrCode err
-                msg  = svnErrMsg  err
-            in
-              fail $ "SvnError: " ++ show code ++ ": " ++ msg