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.
This commit is contained in:
parent
78a67f29f8
commit
9f4ffe65e9
9 changed files with 156 additions and 87 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue