aboutsummaryrefslogtreecommitdiff
path: root/Types
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-09-15 16:30:49 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-09-15 16:30:49 -0400
commit2d3f18876550ee2e37a60aea1c0faaa369606ae0 (patch)
tree5da6331d2e4d03748cf0c00c0cb87d82c78c16c1 /Types
parentc26b2eb2a4f261fd903b02d397737cf6a3a0196b (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 'Types')
-rw-r--r--Types/Remote.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/Types/Remote.hs b/Types/Remote.hs
index 671d90b79..adec32973 100644
--- a/Types/Remote.hs
+++ b/Types/Remote.hs
@@ -27,8 +27,8 @@ module Types.Remote
where
import qualified Data.Map as M
-import Data.Ord
import qualified System.FilePath.Posix as Posix
+import Data.Ord
import qualified Git
import Types.Key
@@ -201,13 +201,14 @@ data ExportActions a = ExportActions
, renameExport :: Key -> ExportLocation -> ExportLocation -> a Bool
}
--- | All directories down to the ExportLocation, with the deepest ones
--- last.
+-- | All subdirectories down to the ExportLocation, with the deepest ones
+-- last. Does not include the top of the export.
exportedDirectories :: ExportLocation -> [ExportDirectory]
exportedDirectories (ExportLocation f) =
- map (ExportDirectory . Posix.joinPath . reverse) $
- subs [] $ map Posix.dropTrailingPathSeparator $
- Posix.splitPath $ Posix.takeDirectory f
+ map (ExportDirectory . Posix.joinPath . reverse) (subs [] dirs)
where
subs _ [] = []
subs ps (d:ds) = (d:ps) : subs (d:ps) ds
+
+ dirs = map Posix.dropTrailingPathSeparator $
+ reverse $ drop 1 $ reverse $ Posix.splitPath f