[darcs-users] [patch200] Resolve issue1756: new h-s handles emptied directories...

Petr Rockai me at mornfall.net
Wed Mar 24 09:39:50 UTC 2010


Petr Rockai <me at mornfall.net> writes:

> Oh, I see. Mostly means I screwed up the testcase and got lulled by it
> into thinking this was it. I'll look into this some more, then. :\

This should be a proper fix... (also rolls back the previous version).

diff -rN -u -p old-hashed-storage-0.4/Storage/Hashed/Index.hs new-hashed-storage-0.4/Storage/Hashed/Index.hs
--- old-hashed-storage-0.4/Storage/Hashed/Index.hs      2010-03-24 10:38:08.000000000 +0100
+++ new-hashed-storage-0.4/Storage/Hashed/Index.hs      2010-03-24 10:38:08.000000000 +0100
@@ -261,9 +261,7 @@ readDir index state item =
            subs off | off < following = do
              result <- readItem index $ substate { start = off }
              rest <- subs $ next result
-             case treeitem result of
-               Nothing -> return $! rest
-               Just _  -> return $! (name (resitem result) $ dirlength substate, result) : rest
+             return $! (name (resitem result) $ dirlength substate, result) : rest
            subs coff | coff == following = return []
                      | otherwise = fail $ "Offset mismatch at " ++ show coff ++
                                           " (ends at " ++ show following ++ ")"
@@ -271,8 +269,9 @@ readDir index state item =
        inferiors <- if want then subs $ start substate
                             else return []
 
-       let we_changed = or [ changed x | (_, x) <- inferiors ] || leaf
-           leaf = null inferiors
+       let we_changed = or [ changed x | (_, x) <- inferiors ] || nullleaf
+           nullleaf = null inferiors && oldhash == nullsha
+           nullsha = SHA256 (BS.replicate 32 0)
            tree' = makeTree [ (n, fromJust $ treeitem s) | (n, s) <- inferiors, isJust $ treeitem s ]
            treehash = we_changed ? (hashtree index tree', oldhash)
            tree = tree' { treeHash = treehash }

Yours,
   Petr.


More information about the darcs-users mailing list