summaryrefslogtreecommitdiff
path: root/Database
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-09-15 15:04:29 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-09-15 15:22:53 -0400
commit373a4dfc331386cf66add44ea751c09e86440bfb (patch)
tree16c2df9fc3624a125bd64305d1b8a30faca212b7 /Database
parent4fde30fcd9cee040622309f2392a8c0a645a3069 (diff)
remove empty directories when removing from export
The subtle part of this is what happens when the remote fails to remove an empty directory. The removal from the export needs to fail in that case, so the removal will be tried again later. However, removeExportLocation has already been run and changed the export db, so if the next run checks getExportLocation, it might decide nothing remains to be done, leaving the empty directory. Dealt with that by making removeEmptyDirectories, handle a failure by calling addExportLocation, reverting the database changes so the next run will be guaranteed to try deleting the empty directory again. This commit was sponsored by Thomas Hochstein on Patreon.
Diffstat (limited to 'Database')
-rw-r--r--Database/Export.hs12
1 files changed, 1 insertions, 11 deletions
diff --git a/Database/Export.hs b/Database/Export.hs
index eb644efc7..cfd3f7745 100644
--- a/Database/Export.hs
+++ b/Database/Export.hs
@@ -28,11 +28,10 @@ import qualified Database.Queue as H
import Database.Init
import Annex.Locations
import Annex.Common hiding (delete)
-import Types.Remote (ExportLocation(..), ExportDirectory(..))
+import Types.Remote (ExportLocation(..), ExportDirectory(..), exportedDirectories)
import Database.Persist.TH
import Database.Esqueleto hiding (Key)
-import qualified System.FilePath.Posix as Posix
newtype ExportHandle = ExportHandle H.DbQueue
@@ -114,12 +113,3 @@ isExportDirectoryEmpty (ExportHandle h) (ExportDirectory d) = H.queryDbQueue h $
return $ null l
where
ed = toSFilePath d
-
-exportedDirectories :: ExportLocation -> [ExportDirectory]
-exportedDirectories (ExportLocation f) =
- map (ExportDirectory . Posix.joinPath . reverse) $
- subs [] $ map Posix.dropTrailingPathSeparator $
- Posix.splitPath $ Posix.takeDirectory f
- where
- subs _ [] = []
- subs ps (d:ds) = (d:ps) : subs (d:ps) ds