diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-09-18 14:24:42 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-09-18 14:27:50 -0400 |
commit | 2980ca009586c4373b127ce688694bd84674625a (patch) | |
tree | 8a17108662ddada9bff5201485676fa13fa5cff8 /Database | |
parent | a5e968bb8d4c608c33463160ea2b583a3e34b8fc (diff) |
update ExportTree table efficiently
Use same diff and key lookup except when the whole tree has to be
scanned.
This commit was sponsored by Peter Hogg on Patreon.
Diffstat (limited to 'Database')
-rw-r--r-- | Database/Export.hs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/Database/Export.hs b/Database/Export.hs index 7dae408fa..ad106f84e 100644 --- a/Database/Export.hs +++ b/Database/Export.hs @@ -22,7 +22,10 @@ module Database.Export ( getExportedLocation, isExportDirectoryEmpty, getExportTree, + addExportTree, + removeExportTree, updateExportTree, + updateExportTree', ExportedId, ExportTreeId, ExportedDirectoryId, @@ -183,18 +186,22 @@ updateExportTree h old new = do (diff, cleanup) <- inRepo $ Git.DiffTree.diffTreeRecursive old new forM_ diff $ \i -> do - let loc = mkExportLocation $ getTopFilePath $ - Git.DiffTree.file i srcek <- getek (Git.DiffTree.srcsha i) - case srcek of - Nothing -> return () - Just k -> liftIO $ removeExportTree h (asKey k) loc dstek <- getek (Git.DiffTree.dstsha i) - case dstek of - Nothing -> return () - Just k -> liftIO $ addExportTree h (asKey k) loc + updateExportTree' h srcek dstek i void $ liftIO cleanup where getek sha | sha == nullSha = return Nothing | otherwise = Just <$> exportKey sha + +updateExportTree' :: ExportHandle -> Maybe ExportKey -> Maybe ExportKey -> Git.DiffTree.DiffTreeItem-> Annex () +updateExportTree' h srcek dstek i = do + case srcek of + Nothing -> return () + Just k -> liftIO $ removeExportTree h (asKey k) loc + case dstek of + Nothing -> return () + Just k -> liftIO $ addExportTree h (asKey k) loc + where + loc = mkExportLocation $ getTopFilePath $ Git.DiffTree.file i |