From 5257991a8533b45566428ee2679f57a8f75dc065 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 19 Nov 2013 16:31:21 -0400 Subject: fix file mode problems --- Git/Destroyer.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Git/Destroyer.hs b/Git/Destroyer.hs index baffa05..74a7941 100644 --- a/Git/Destroyer.hs +++ b/Git/Destroyer.hs @@ -66,7 +66,9 @@ instance Arbitrary FileSelector where selectFile :: [FilePath] -> FileSelector -> FilePath selectFile sortedfs (FileSelector n) = sortedfs !! (n `mod` length sortedfs) -{- Generates random Damage. -} +{- Generates random Damage. + - + - TODO: sample' only seems to go up to 20 for files? -} generateDamage :: IO [Damage] generateDamage = sample' (arbitrary :: Gen Damage) @@ -81,9 +83,8 @@ applyDamage l r = do -- If the file was already removed by a previous Damage, -- it's skipped. whenM (doesFileExist f) $ - withModifiedFileMode f (addModes [ownerWriteMode]) $ - applyDamageAction action f - `catchIO` \e -> error ("Failed to apply " ++ show action ++ " " ++ show f ++ ": " ++ show e) + applyDamageAction action f + `catchIO` \e -> error ("Failed to apply " ++ show action ++ " " ++ show f ++ ": " ++ show e ++ "(total damage: " ++ show l ++ ")") applyDamageAction :: DamageAction -> FilePath -> IO () applyDamageAction Empty f = changeFile f $ do @@ -99,7 +100,7 @@ applyDamageAction (PrependGarbage garbage) f = changeFile f $ do B.writeFile f $ B.concat [garbage, b] -- When the byte is past the end of the file, wrap around. -- Does nothing to empty file. -applyDamageAction (CorruptByte n garbage) f = do +applyDamageAction (CorruptByte n garbage) f = changeFile f $ do b <- B.readFile f let len = B.length b unless (len == 0) $ do -- cgit v1.2.3