diff options
author | 2017-09-15 16:30:49 -0400 | |
---|---|---|
committer | 2017-09-15 16:30:49 -0400 | |
commit | 2d3f18876550ee2e37a60aea1c0faaa369606ae0 (patch) | |
tree | 5da6331d2e4d03748cf0c00c0cb87d82c78c16c1 /Remote/Helper | |
parent | c26b2eb2a4f261fd903b02d397737cf6a3a0196b (diff) |
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).
Diffstat (limited to 'Remote/Helper')
-rw-r--r-- | Remote/Helper/Export.hs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/Remote/Helper/Export.hs b/Remote/Helper/Export.hs index 101124cef..3067ac837 100644 --- a/Remote/Helper/Export.hs +++ b/Remote/Helper/Export.hs @@ -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) |