aboutsummaryrefslogtreecommitdiff
path: root/Logs/FsckResults.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-12 15:18:43 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-12 15:18:43 -0400
commit3a7b7c8ac97f263e5fdf6281ef6812aba4af0042 (patch)
tree42be53b2ff001d4c8b3471aea090c68de33de879 /Logs/FsckResults.hs
parent4d79d2327819111f97954e10dce2c8ce53b0ab31 (diff)
fully fix fsck memory use by iterative fscking
Not very well tested, but I'm sure it doesn't eg, loop forever.
Diffstat (limited to 'Logs/FsckResults.hs')
-rw-r--r--Logs/FsckResults.hs28
1 files changed, 17 insertions, 11 deletions
diff --git a/Logs/FsckResults.hs b/Logs/FsckResults.hs
index 3538bdc40..619dd586c 100644
--- a/Logs/FsckResults.hs
+++ b/Logs/FsckResults.hs
@@ -23,25 +23,31 @@ writeFsckResults u fsckresults = do
logfile <- fromRepo $ gitAnnexFsckResultsLog u
liftIO $
case fsckresults of
- FsckFailed -> store S.empty logfile
- FsckFoundMissing s
+ FsckFailed -> store S.empty False logfile
+ FsckFoundMissing s t
| S.null s -> nukeFile logfile
- | otherwise -> store s logfile
+ | otherwise -> store s t logfile
where
- store s logfile = do
+ store s t logfile = do
createDirectoryIfMissing True (parentDir logfile)
- liftIO $ viaTmp writeFile logfile $ serialize s
- serialize = unlines . map fromRef . S.toList
+ liftIO $ viaTmp writeFile logfile $ serialize s t
+ serialize s t =
+ let ls = map fromRef (S.toList s)
+ in if t
+ then unlines ("truncated":ls)
+ else unlines ls
readFsckResults :: UUID -> Annex FsckResults
readFsckResults u = do
logfile <- fromRepo $ gitAnnexFsckResultsLog u
- liftIO $ catchDefaultIO (FsckFoundMissing S.empty) $
- deserialize <$> readFile logfile
+ liftIO $ catchDefaultIO (FsckFoundMissing S.empty False) $
+ deserialize . lines <$> readFile logfile
where
- deserialize l =
- let s = S.fromList $ map Ref $ lines l
- in if S.null s then FsckFailed else FsckFoundMissing s
+ deserialize ("truncated":ls) = deserialize' ls True
+ deserialize ls = deserialize' ls False
+ deserialize' ls t =
+ let s = S.fromList $ map Ref ls
+ in if S.null s then FsckFailed else FsckFoundMissing s t
clearFsckResults :: UUID -> Annex ()
clearFsckResults = liftIO . nukeFile <=< fromRepo . gitAnnexFsckResultsLog