on master help sign in
remove-old-stack-work-libs.hs: check more carefully for libdir hash
6c6708bJens Petersen
etc/diskspace/remove-old-stack-work-libs.hs+9−1
@@ -23,7 +23,9 @@ main = do
23 pkgDirName p =
23 pkgDirName p =
24 if countDashes p < 2
24 if countDashes p < 2
25 then error $ p ++ " not in name-version-hash format"
25 then error $ p ++ " not in name-version-hash format"
26+ else let nv_ = dropEnd 22 p in
26− else (removeDashSegment . removeDashSegment) p
27+ if last nv_ == '-' then removeDashSegment $ init nv_
28+ else error $ p ++ " not in name-version-hash format"
27
29
28 countDashes = length . filter (== '-')
30 countDashes = length . filter (== '-')
29
31
@@ -47,3 +49,9 @@ main = do
47 return $ map fst $ sortBy compareSnd fileTimes
49 return $ map fst $ sortBy compareSnd fileTimes
48
50
49 compareSnd (_,t1) (_,t2) = compare t1 t2
51 compareSnd (_,t1) (_,t2) = compare t1 t2
52+
53+-- from Data.List.Extra
54+dropEnd :: Int -> [a] -> [a]
55+dropEnd i xs = f xs (drop i xs)
56+ where f (x:xs) (y:ys) = x : f xs ys
57+ f _ _ = []