summaryrefslogtreecommitdiff
path: root/Remote/WebDAV.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-09-15 13:15:47 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-09-15 13:18:21 -0400
commit269c6925ded8145aaea1f8ccdbb747f65f076131 (patch)
tree53baca2cb95215158d98e008614f4e7ab5e79e95 /Remote/WebDAV.hs
parent1890f6ee7a791db909055b4760919e6979ddd3ae (diff)
implement removeExportDirectory
Not yet called by Command.Export. WebDAV needs this to clean up empty collections. Also, example.sh turned out to not be cleaning up directories when removing content from them, so it made sense for it to use this. Remote.Directory did not need it, and since its cleanup method for empty directories is more efficient than what Command.Export will need to do to find empty directories, it uses Nothing so that extra work can be avoided. This commit was sponsored by Thom May on Patreon.
Diffstat (limited to 'Remote/WebDAV.hs')
-rw-r--r--Remote/WebDAV.hs17
1 files changed, 12 insertions, 5 deletions
diff --git a/Remote/WebDAV.hs b/Remote/WebDAV.hs
index 8c72365e6..61fc70324 100644
--- a/Remote/WebDAV.hs
+++ b/Remote/WebDAV.hs
@@ -73,8 +73,10 @@ gen r u c gc = new <$> remoteCost gc expensiveRemoteCost
, exportActions = withDAVHandle this $ \mh -> return $ ExportActions
{ storeExport = storeExportDav mh
, retrieveExport = retrieveExportDav mh
- , removeExport = removeExportDav mh
, checkPresentExport = checkPresentExportDav this mh
+ , removeExport = removeExportDav mh
+ , removeExportDirectory = Just $
+ removeExportDirectoryDav mh
, renameExport = renameExportDav mh
}
, whereisKey = Nothing
@@ -189,10 +191,6 @@ retrieveExportDav mh _k loc d p = runExport mh $ \_dav -> do
retrieveHelper (exportLocation loc) d p
return True
-removeExportDav :: Maybe DavHandle -> Key -> ExportLocation -> Annex Bool
-removeExportDav mh _k loc = runExport mh $ \_dav ->
- removeHelper (exportLocation loc)
-
checkPresentExportDav :: Remote -> Maybe DavHandle -> Key -> ExportLocation -> Annex Bool
checkPresentExportDav r mh _k loc = case mh of
Nothing -> giveup $ name r ++ " not configured"
@@ -200,6 +198,15 @@ checkPresentExportDav r mh _k loc = case mh of
v <- goDAV h $ existsDAV (exportLocation loc)
either giveup return v
+removeExportDav :: Maybe DavHandle -> Key -> ExportLocation -> Annex Bool
+removeExportDav mh _k loc = runExport mh $ \_dav ->
+ removeHelper (exportLocation loc)
+
+removeExportDirectoryDav :: Maybe DavHandle -> ExportDirectory -> Annex Bool
+removeExportDirectoryDav mh (ExportDirectory dir) = runExport mh $ \_dav ->
+ safely (inLocation dir delContentM)
+ >>= maybe (return False) (const $ return True)
+
renameExportDav :: Maybe DavHandle -> Key -> ExportLocation -> ExportLocation -> Annex Bool
renameExportDav Nothing _ _ _ = return False
renameExportDav (Just h) _k src dest