diff options
author | Joey Hess <joey@kitenet.net> | 2011-03-22 20:31:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-03-22 20:31:22 -0400 |
commit | c1dc4079419cff94cca72441d5e67a866110ec7e (patch) | |
tree | de0fee3eacb276f3e008c86320b8ffe1345f5892 /Utility.hs | |
parent | 5d759195618a96ce745b8ee559b439c86426a0f3 (diff) |
Fix space leak in fsck and drop commands.
The space leak was somehow caused by this line:
absfiles <- mapM absPath files
I confess, I don't quite understand why this caused bad buffering,
but apparently the whole pipeline from git-ls-files backed up at that
point.
Happily, rewriting the code to only get the cwd once and use a pure
function to calculate absfiles clears it up, and should be a little more
efficient in syscalls too.
Diffstat (limited to 'Utility.hs')
-rw-r--r-- | Utility.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Utility.hs b/Utility.hs index e63fa1f6b..8312335f8 100644 --- a/Utility.hs +++ b/Utility.hs @@ -12,6 +12,7 @@ module Utility ( readFileStrict, parentDir, absPath, + absPathFrom, relPathCwdToDir, relPathDirToDir, boolSystem, @@ -165,8 +166,14 @@ dirContains a b = a == b || a' == b' || (a'++"/") `isPrefixOf` b' absPath :: FilePath -> IO FilePath absPath file = do cwd <- getCurrentDirectory + return $ absPathFrom cwd file + +{- Converts a filename into a normalized, absolute path + - from the specified cwd. -} +absPathFrom :: FilePath -> FilePath -> FilePath +absPathFrom cwd file = case absNormPath cwd file of - Just f -> return f + Just f -> f Nothing -> error $ "unable to normalize " ++ file {- Constructs a relative path from the CWD to a directory. |