avoid unncessary db queries when exported directory can't be empty
In rename foo/bar to foo/baz, foo can't be empty. In delete zxyyz, there's no exported directory (top doesn't count).
This commit is contained in:
parent
af82b2229c
commit
e54a05612e
3 changed files with 24 additions and 19 deletions
|
@ -151,18 +151,20 @@ adjustExportable r = case M.lookup "exporttree" (config r) of
|
|||
-- exported file, and after calling removeExportLocation and flushing the
|
||||
-- database.
|
||||
removeEmptyDirectories :: ExportActions Annex -> ExportHandle -> ExportLocation -> [Key] -> Annex Bool
|
||||
removeEmptyDirectories ea db loc ks = case removeExportDirectory ea of
|
||||
Nothing -> return True
|
||||
Just removeexportdirectory -> do
|
||||
ok <- allM (go removeexportdirectory)
|
||||
(reverse (exportedDirectories loc))
|
||||
unless ok $ liftIO $ do
|
||||
-- Add back to export database, so this is
|
||||
-- tried again next time.
|
||||
forM_ ks $ \k ->
|
||||
addExportLocation db k loc
|
||||
flushDbQueue db
|
||||
return ok
|
||||
removeEmptyDirectories ea db loc ks
|
||||
| null (exportedDirectories loc) = return True
|
||||
| otherwise = case removeExportDirectory ea of
|
||||
Nothing -> return True
|
||||
Just removeexportdirectory -> do
|
||||
ok <- allM (go removeexportdirectory)
|
||||
(reverse (exportedDirectories loc))
|
||||
unless ok $ liftIO $ do
|
||||
-- Add back to export database, so this is
|
||||
-- tried again next time.
|
||||
forM_ ks $ \k ->
|
||||
addExportLocation db k loc
|
||||
flushDbQueue db
|
||||
return ok
|
||||
where
|
||||
go removeexportdirectory d =
|
||||
ifM (liftIO $ isExportDirectoryEmpty db d)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue