Fix directory special remote's cleanup of empty export directories.

Was trying to rmdir the file, which had already been deleted, and when that
failed, it skipped trying to delete the parent directories.

Noticed the bug through testremote, but it can't itself detect such
problems as there is no enumeration in the API.

This commit was sponsored by Brock Spratlen on Patreon.
This commit is contained in:
Joey Hess 2017-11-08 14:38:24 -04:00
parent 1d0bf44173
commit 0e4bdd21a8
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 4 additions and 2 deletions

View file

@ -10,6 +10,7 @@ git-annex (6.20171027) UNRELEASED; urgency=medium
Thanks, Eric Siegerman Thanks, Eric Siegerman
* Makefile improvement for BUILDER=stack, use stack to run ghc. * Makefile improvement for BUILDER=stack, use stack to run ghc.
* testremote: Test exporttree. * testremote: Test exporttree.
* Fix directory special remote's cleanup of empty export directories.
-- Joey Hess <id@joeyh.name> Mon, 30 Oct 2017 12:01:45 -0400 -- Joey Hess <id@joeyh.name> Mon, 30 Oct 2017 12:01:45 -0400

View file

@ -276,10 +276,11 @@ renameExportM d _k oldloc newloc = liftIO $ catchBoolIO $ do
exportPath :: FilePath -> ExportLocation -> FilePath exportPath :: FilePath -> ExportLocation -> FilePath
exportPath d loc = d </> fromExportLocation loc exportPath d loc = d </> fromExportLocation loc
{- Removes the ExportLocation directory and its parents, so long as {- Removes the ExportLocation's parent directory and its parents, so long as
- they're empty, up to but not including the topdir. -} - they're empty, up to but not including the topdir. -}
removeExportLocation :: FilePath -> ExportLocation -> IO () removeExportLocation :: FilePath -> ExportLocation -> IO ()
removeExportLocation topdir loc = go (Just $ fromExportLocation loc) (Right ()) removeExportLocation topdir loc =
go (Just $ takeDirectory $ fromExportLocation loc) (Right ())
where where
go _ (Left _e) = return () go _ (Left _e) = return ()
go Nothing _ = return () go Nothing _ = return ()