Your message dated Fri, 08 Aug 2014 16:20:05 +0000
with message-id <[email protected]>
and subject line Bug#757401: fixed in haskell-dav 1.0-1
has caused the Debian Bug report #757401,
regarding add withDAVContext, runDAVContext, inDAVLocation, getDAVLocation
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
757401: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=757401
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Source: haskell-dav
Severity: normal
Tags: patch

Please apply the two attached patches, which add stuff git-annex needs
to use DAV more efficiently.

-- 
see shy jo
From e9cc0657853024d32eb2c5a62d8e8a44882fe018 Mon Sep 17 00:00:00 2001
From: Joey Hess <[email protected]>
Date: Wed, 6 Aug 2014 16:16:44 -0400
Subject: [PATCH 1/2] add withDAVContext and runDAVContext

The use case for this is that I have code that cannot run in the DAV monad,
but I want it to run multiple DAV operations while reusing the context,
particularly the http manager's open connection.
---
 Network/Protocol/HTTP/DAV.hs | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/Network/Protocol/HTTP/DAV.hs b/Network/Protocol/HTTP/DAV.hs
index c8d76ea..06d1ee9 100644
--- a/Network/Protocol/HTTP/DAV.hs
+++ b/Network/Protocol/HTTP/DAV.hs
@@ -24,6 +24,8 @@
 module Network.Protocol.HTTP.DAV (
     DAVT(..)
   , evalDAVT
+  , withDAVContext
+  , runDAVContext
   , setCreds
   , setDepth
   , setResponseTimeout
@@ -56,7 +58,7 @@ import Network.Protocol.HTTP.DAV.TH
 
 import Control.Applicative (liftA2, Applicative)
 import Control.Error (EitherT(..))
-import Control.Exception.Lifted (catchJust, finally, bracketOnError)
+import Control.Exception.Lifted (catchJust, finally, bracket, bracketOnError)
 import Control.Lens ((^.), (.=), (%=))
 import Control.Monad (liftM, liftM2, when, MonadPlus)
 import Control.Monad.Base (MonadBase(..))
@@ -64,7 +66,7 @@ import Control.Monad.Error (MonadError)
 import Control.Monad.Fix (MonadFix)
 import Control.Monad.Trans (lift, MonadTrans)
 import Control.Monad.IO.Class (liftIO, MonadIO)
-import Control.Monad.State (evalStateT, get, MonadState, StateT)
+import Control.Monad.State (evalStateT, runStateT, get, MonadState, StateT)
 import Control.Monad.Trans.Control (MonadBaseControl(..))
 
 import qualified Data.ByteString as B
@@ -95,13 +97,29 @@ instance MonadBaseControl b m => MonadBaseControl b (DAVT m) where
 instance MonadTrans DAVT where
     lift = DAVT . lift . lift
 
-evalDAVT :: MonadIO m => String -> DAVT m a -> m (Either String a)
+type DAVURL = String
+
+evalDAVT :: MonadIO m => DAVURL -> DAVT m a -> m (Either String a)
 evalDAVT u f = do
+    ctx <- mkDAVContext u
+    r <- (evalStateT . runEitherT . runDAVT) f ctx
+    closeDAVContext ctx
+    return r
+
+mkDAVContext :: MonadIO m => DAVURL -> m DAVContext
+mkDAVContext u = liftIO $ do
     mgr <- liftIO $ newManager tlsManagerSettings
     req <- liftIO $ parseUrl u
-    r <- (evalStateT . runEitherT . runDAVT) f $ DAVContext [] req B.empty B.empty [] Nothing mgr Nothing "hDav-using application"
-    liftIO $ closeManager mgr
-    return r
+    return $ DAVContext [] req B.empty B.empty [] Nothing mgr Nothing "hDav-using application"
+
+closeDAVContext :: MonadIO m => DAVContext -> m ()
+closeDAVContext ctx = liftIO $ closeManager (ctx ^. httpManager)
+
+withDAVContext :: (MonadIO m, MonadBaseControl IO m) => DAVURL -> (DAVContext -> m a) -> m a
+withDAVContext u = bracket (mkDAVContext u) closeDAVContext 
+
+runDAVContext :: MonadIO m => DAVContext -> DAVT m a -> m (Either String a, DAVContext)
+runDAVContext ctx f = (runStateT . runEitherT . runDAVT) f ctx
 
 choke :: IO (Either String a) -> IO a
 choke f = do
-- 
2.1.0.rc1

From aa8fea0da0388fe8e76798587a915a75f731f548 Mon Sep 17 00:00:00 2001
From: Joey Hess <[email protected]>
Date: Wed, 6 Aug 2014 18:18:02 -0400
Subject: [PATCH 2/2] add inDAVLocation and getDAVLocation

inDAVLocation is useful for composing DAV monad actions that operate on
different locations within the same DAV repository.

getDAVLocation can be useful when writing code that might need to eg,
create the parent collection that will hold the current location.

Needed to pull in utf-8 string in order to convert from Request paths
to strings.
---
 DAV.cabal                    |  4 +++-
 Network/Protocol/HTTP/DAV.hs | 41 ++++++++++++++++++++++++++++++++++++++++-
 debian/control               |  3 +++
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/DAV.cabal b/DAV.cabal
index bf54f44..85eb50e 100644
--- a/DAV.cabal
+++ b/DAV.cabal
@@ -1,5 +1,5 @@
 name:                DAV
-version:             0.6.2
+version:             0.7.0
 synopsis:            RFC 4918 WebDAV support
 description:
    This is a library for the Web Distributed Authoring and Versioning
@@ -40,6 +40,7 @@ library
                      , mtl >= 2.1
                      , transformers >= 0.3
                      , transformers-base
+                     , utf8-string
                      , xml-conduit >= 1.0          && < 1.3
                      , xml-hamlet >= 0.4           && <= 0.5
 executable hdav
@@ -63,6 +64,7 @@ executable hdav
                      , optparse-applicative >= 0.5.0
                      , transformers >= 0.3
                      , transformers-base
+                     , utf8-string
                      , xml-conduit >= 1.0          && < 1.3
                      , xml-hamlet >= 0.4           && <= 0.5
 
diff --git a/Network/Protocol/HTTP/DAV.hs b/Network/Protocol/HTTP/DAV.hs
index 06d1ee9..ca8fe59 100644
--- a/Network/Protocol/HTTP/DAV.hs
+++ b/Network/Protocol/HTTP/DAV.hs
@@ -51,6 +51,8 @@ module Network.Protocol.HTTP.DAV (
   , putContentM'
   , withLockIfPossible
   , withLockIfPossibleForDelete
+  , inDAVLocation
+  , getDAVLocation
   , module Network.Protocol.HTTP.DAV.TH
 ) where
 
@@ -72,11 +74,12 @@ import Control.Monad.Trans.Control (MonadBaseControl(..))
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Char8 as BC8
 import qualified Data.ByteString.Lazy as BL
+import qualified Data.ByteString.UTF8 as UTF8B
 import qualified Data.Map as Map
 
 import Data.Maybe (catMaybes, fromMaybe)
 
-import Network.HTTP.Client (RequestBody(..), httpLbs, parseUrl, applyBasicAuth, Request(..), Response(..), newManager, closeManager, HttpException(..), BodyReader, withResponse)
+import Network.HTTP.Client (RequestBody(..), httpLbs, parseUrl, applyBasicAuth, Request(..), Response(..), newManager, closeManager, HttpException(..), BodyReader, withResponse, path)
 import Network.HTTP.Client.TLS (tlsManagerSettings)
 import Network.HTTP.Types (hContentType, Method, Status, RequestHeaders, unauthorized401, conflict409)
 
@@ -403,3 +406,39 @@ calendarquery = XML.Document (XML.Prologue [] Nothing []) root []
 <C:filter>
   <C:comp-filter name="VCALENDAR">
 |]
+
+-- | Normally, DAVT actions act on the url that is provided to eg, evalDAVT.
+-- Sometimes, it's useful to adjust the url that is acted on, while
+-- remaining in the same DAV session.
+--
+-- inLocation temporarily adjusts the url's path, while performing a
+-- DAVT action.
+--
+-- For example:
+--
+-- > import System.FilePath.Posix -- posix for url path manipulation
+-- > 
+-- > mkColRecursive d = do
+-- >   let parent = takeDirectory d
+-- >   when (parent /= d) $
+-- >     mkColRecursive parent
+-- >   inDavLocation (</> d) mkCol
+--
+-- Note that operations that modify the DAVContext 
+-- (such as setCreds and setCreds) can be run inside davLocation,
+-- but will not have any effect on the calling DAVContext.
+inDAVLocation :: MonadIO m => (String -> String) -> DAVT m a -> DAVT m a
+inDAVLocation f a = do
+    ctx <- get
+    let r = ctx ^. baseRequest
+    let r' = r { path = adjustpath r }
+    let ctx' = ctx { _baseRequest = r' }
+    lift $ either error return =<< (evalStateT . runEitherT . runDAVT) a ctx'
+  where
+    adjustpath = UTF8B.fromString . f . UTF8B.toString . path
+
+-- | Gets the path of the url that DAVT actions will act on.
+getDAVLocation :: Monad m => DAVT m String
+getDAVLocation = do
+    ctx <- get
+    return (UTF8B.toString $ path $ ctx ^. baseRequest)
diff --git a/debian/control b/debian/control
index e0f3ed3..d538a9b 100644
--- a/debian/control
+++ b/debian/control
@@ -37,6 +37,8 @@ Build-Depends: debhelper (>= 9)
  , libghc-transformers-prof
  , libghc-transformers-base-dev
  , libghc-transformers-base-prof
+ , libghc-utf8-string-dev
+ , libghc-utf8-string-prof
  , libghc-xml-conduit-dev (>= 1.0)
  , libghc-xml-conduit-dev (<< 1.3)
  , libghc-xml-conduit-prof
@@ -58,6 +60,7 @@ Build-Depends-Indep: ghc-doc
  , libghc-optparse-applicative-doc
  , libghc-transformers-doc
  , libghc-transformers-base-doc
+ , libghc-utf8-string-doc
  , libghc-xml-conduit-doc
  , libghc-xml-hamlet-doc
 Standards-Version: 3.9.5
-- 
2.1.0.rc1

Attachment: signature.asc
Description: Digital signature


--- End Message ---
--- Begin Message ---
Source: haskell-dav
Source-Version: 1.0-1

We believe that the bug you reported is fixed in the latest version of
haskell-dav, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Clint Adams <[email protected]> (supplier of updated haskell-dav package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Fri, 08 Aug 2014 11:39:21 -0400
Source: haskell-dav
Binary: hdav libghc-dav-dev libghc-dav-prof libghc-dav-doc
Architecture: source all
Version: 1.0-1
Distribution: unstable
Urgency: medium
Maintainer: Debian Haskell Group 
<[email protected]>
Changed-By: Clint Adams <[email protected]>
Description:
 hdav       - command-line WebDAV client
 libghc-dav-dev - RFC 4918 WebDAV support
 libghc-dav-doc - RFC 4918 WebDAV support; documentation
 libghc-dav-prof - RFC 4918 WebDAV support; profiling libraries
Closes: 757401
Changes:
 haskell-dav (1.0-1) unstable; urgency=medium
 .
   * New upstream version.
     - New functions from Joey Hess.  closes: #757401.
Checksums-Sha1:
 b5eb345e9490a1570facb43c82be629bf240bb47 3667 haskell-dav_1.0-1.dsc
 737f8d9e101870f99c03187476a9600043e95ab8 20125 haskell-dav_1.0.orig.tar.gz
 0c3129da3275a3c59dba071cd4bc00c9fbcb7e8a 2348 haskell-dav_1.0-1.debian.tar.xz
 0225641b7741640962b7bf2405fbd4b326d1133b 42134 libghc-dav-doc_1.0-1_all.deb
Checksums-Sha256:
 0b971995c9aaa0e690d8e4353d76f4fa274855709c9882e47effe3f775dece82 3667 
haskell-dav_1.0-1.dsc
 e94f0074665e93436e8b135902eb9252281cfa6b1ab59b34a203d88d0b07b75e 20125 
haskell-dav_1.0.orig.tar.gz
 2f8ed36706fd2f88148ed6c96a89faaffd80efd57da04697918c0c73855269ad 2348 
haskell-dav_1.0-1.debian.tar.xz
 c2cbd9b9d57a534e378000be96969999bdbf6f7deacbae4e6ae215c48cb218e2 42134 
libghc-dav-doc_1.0-1_all.deb
Files:
 027f71c7612658a82c5ca163a9be6087 42134 doc extra libghc-dav-doc_1.0-1_all.deb
 df0f0f472ff72dbe34c3aaffc66b4c7e 3667 haskell extra haskell-dav_1.0-1.dsc
 0724cd99a4f9539eb9b904c2b8091a63 20125 haskell extra 
haskell-dav_1.0.orig.tar.gz
 8f483a8f931db9fc12cadd34e649d66f 2348 haskell extra 
haskell-dav_1.0-1.debian.tar.xz

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Debian!

iQJ8BAEBCgBmBQJT5PDvXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ3NTgxRUM4NzQwNTNFNkM4MDc3OTFCOUI1
NTkyMzMxRTE5OUQzOEE4AAoJEFWSMx4ZnTioD10P/R0yLHCoqYbTx5675zXRD3UK
ilWVukiPgy5eHVGn/N0SFdtEPCGF+1V95UljYKbbH23czihkROwG/CRJd/rJpa28
r9sPe3ZsHILp6MumT47zvftXyGCSsJ53FLQBL26TUADMuyxUFwR8thnm/bPsybDP
S6JDWRlQJKpZjfquGZJE0Leqggm678wpxkD7CrWxyG3Ju4CenLy86wtOBy8aiMZX
SKvLjTyp8AU7Ppf7NraGRtnetrqw8d0lLJ0kYtxsckwCM8QwAaED+yhp7hlGxOZX
lAkXBGSu0Fpl7RAUrWq0G3Y4VraRLb87Kq/pO/u7hMJAKPXS2TSTil4GJlSnEaFb
xAnwARkXtEg1ATK/eYFxYd0VoSvE36z+1EGarqlC+w7FXGnOeeg7KBTN8iis0eYl
lFSpBdySavQmG1UcEyidf+xWS2ylbBmxT0vFgOZfHH3bO0IAp2iU2LQHq+AwSuPv
Lj2+rzEXuXo16Coc7nchWvSfVs1R5cOXkhMih6sWM2To1ko4eTgAY/f5PVlXPUQr
DV8zulh3ZB7VPCb5KHh3nt8zzHx2TxNStB3Lj+KXxfmi12tSBiP5ew2vxfGmzysa
/OQWB0JhDDDxP1NT+kWz62vgBU49nRy6tmiIFu4PMd6BawFMSRRwp9gf6xKOmQko
3uofvU0zGntXbQE7jyD9
=QDKu
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to