etc/diskspace: include dir in error when more than one subdir

[skip ci]
This commit is contained in:
Jens Petersen 2023-06-18 00:35:33 +02:00
parent e9b705d346
commit c322900508

View File

@ -98,10 +98,14 @@ withOneDirectory_ act = do
ls <- listDirectory "."
case ls of
[l] -> withCurrentDirectory l act
_ -> error $ "more than one directory found: " ++ unwords ls
_ -> do
cwd <- getCurrentDirectory
error $ "more than one directory found in " ++ cwd ++ ": " ++ unwords ls
withOneDirectory act = do
ls <- listDirectory "."
case ls of
[l] -> withCurrentDirectory l $ act l
_ -> error $ "more than one directory found: " ++ unwords ls
_ -> do
cwd <- getCurrentDirectory
error $ "more than one directory found in " ++ cwd ++ ": " ++ unwords ls