mirror of
https://github.com/commercialhaskell/stackage.git
synced 2026-01-11 23:08:30 +01:00
remove-old-stack-work-libs.hs: check more carefully for libdir hash
to avoid accidents, eg if run in wrong directory
This commit is contained in:
parent
9ba15fcde0
commit
6c6708be00
@ -23,7 +23,9 @@ main = do
|
||||
pkgDirName p =
|
||||
if countDashes p < 2
|
||||
then error $ p ++ " not in name-version-hash format"
|
||||
else (removeDashSegment . removeDashSegment) p
|
||||
else let nv_ = dropEnd 22 p in
|
||||
if last nv_ == '-' then removeDashSegment $ init nv_
|
||||
else error $ p ++ " not in name-version-hash format"
|
||||
|
||||
countDashes = length . filter (== '-')
|
||||
|
||||
@ -47,3 +49,9 @@ main = do
|
||||
return $ map fst $ sortBy compareSnd fileTimes
|
||||
|
||||
compareSnd (_,t1) (_,t2) = compare t1 t2
|
||||
|
||||
-- from Data.List.Extra
|
||||
dropEnd :: Int -> [a] -> [a]
|
||||
dropEnd i xs = f xs (drop i xs)
|
||||
where f (x:xs) (y:ys) = x : f xs ys
|
||||
f _ _ = []
|
||||
|
||||
Loading…
Reference in New Issue
Block a user