summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-09-13 15:09:52 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-09-13 15:26:56 -0400
commit7cad5617eec4328888929dca553cd7f131d4441a (patch)
tree010ad0cf538be9d25c48382b31b6de2ee0c51d3d /Remote
parentd5563ace55321012e291d1f5ae86e3d34ef52901 (diff)
work around box.com webdav rename bug
Apparently box.com renaming is just buggy. I tried a couple of fixes: * In case the http Manager was opening multiple connections and reaching different backend servers, I tried limiting the number of connections to 1. Didn't help. * To make sure it was not a http connection reuse problem, I tried rewriting how exportAction works, so that the same http connection is clearly open. Didn't help. So, disable renaming of exports for box.com. It would be good to test it with some other webdav server. This commit was sponsored by John Peloquin on Patreon.
Diffstat (limited to 'Remote')
-rw-r--r--Remote/WebDAV.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/Remote/WebDAV.hs b/Remote/WebDAV.hs
index 5e853ae22..8c72365e6 100644
--- a/Remote/WebDAV.hs
+++ b/Remote/WebDAV.hs
@@ -201,9 +201,15 @@ checkPresentExportDav r mh _k loc = case mh of
either giveup return v
renameExportDav :: Maybe DavHandle -> Key -> ExportLocation -> ExportLocation -> Annex Bool
-renameExportDav mh _k src dest = runExport mh $ \dav -> do
- moveDAV (baseURL dav) (exportLocation src) (exportLocation dest)
- return True
+renameExportDav Nothing _ _ _ = return False
+renameExportDav (Just h) _k src dest
+ -- box.com's DAV endpoint has buggy handling of renames,
+ -- so avoid renaming when using it.
+ | boxComUrl `isPrefixOf` baseURL h = return False
+ | otherwise = runExport (Just h) $ \dav -> do
+ maybe noop (void . mkColRecursive) (locationParent (exportLocation dest))
+ moveDAV (baseURL dav) (exportLocation src) (exportLocation dest)
+ return True
runExport :: Maybe DavHandle -> (DavHandle -> DAVT IO Bool) -> Annex Bool
runExport Nothing _ = return False
@@ -213,7 +219,10 @@ configUrl :: Remote -> Maybe URLString
configUrl r = fixup <$> M.lookup "url" (config r)
where
-- box.com DAV url changed
- fixup = replace "https://www.box.com/dav/" "https://dav.box.com/dav/"
+ fixup = replace "https://www.box.com/dav/" boxComUrl
+
+boxComUrl :: URLString
+boxComUrl = "https://dav.box.com/dav/"
type DavUser = B8.ByteString
type DavPass = B8.ByteString