summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-09-18 18:40:16 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-09-18 19:21:41 -0400
commit36533ce176ec653f62fe740f9907f527e4f36361 (patch)
tree0c507668c7d19950efa7877ca2155e71ccdb1472 /Command
parent7576fff0131d4f86dc495d58f62490c3264e0e54 (diff)
merge changes made on other repos into ExportTree
Now when one repository has exported a tree, another repository can get files from the export, after syncing. There's a bug: While the database update works, somehow the database on disk does not get updated, and so the database update is run the next time, etc. Wasn't able to figure out why yet. This commit was sponsored by Ole-Morten Duesund on Patreon.
Diffstat (limited to 'Command')
-rw-r--r--Command/Export.hs28
1 files changed, 26 insertions, 2 deletions
diff --git a/Command/Export.hs b/Command/Export.hs
index 811e2351a..02c64eadf 100644
--- a/Command/Export.hs
+++ b/Command/Export.hs
@@ -27,7 +27,6 @@ import Annex.LockFile
import Logs.Location
import Logs.Export
import Database.Export
-import Remote.Helper.Export
import Messages.Progress
import Utility.Tmp
@@ -129,7 +128,7 @@ seek' o r = do
(\diff -> startUnexport r ea db (Git.DiffTree.file diff) (unexportboth diff))
oldtreesha new
updateExportTree db emptyTree new
- liftIO $ recordDataSource db new
+ liftIO $ recordExportTreeCurrent db new
-- Waiting until now to record the export guarantees that,
-- if this export is interrupted, there are no files left over
@@ -312,3 +311,28 @@ cleanupRename ea db ek src dest = do
if exportDirectories src /= exportDirectories dest
then removeEmptyDirectories ea db src [asKey ek]
else return True
+
+-- | Remove empty directories from the export. Call after removing an
+-- exported file, and after calling removeExportLocation and flushing the
+-- database.
+removeEmptyDirectories :: ExportActions Annex -> ExportHandle -> ExportLocation -> [Key] -> Annex Bool
+removeEmptyDirectories ea db loc ks
+ | null (exportDirectories loc) = return True
+ | otherwise = case removeExportDirectory ea of
+ Nothing -> return True
+ Just removeexportdirectory -> do
+ ok <- allM (go removeexportdirectory)
+ (reverse (exportDirectories loc))
+ unless ok $ liftIO $ do
+ -- Add location back to export database,
+ -- so this is tried again next time.
+ forM_ ks $ \k ->
+ addExportedLocation db k loc
+ flushDbQueue db
+ return ok
+ where
+ go removeexportdirectory d =
+ ifM (liftIO $ isExportDirectoryEmpty db d)
+ ( removeexportdirectory d
+ , return True
+ )