[darcs-devel] [issue2677] pull --reorder fails to copy patches

Ben Franksen bugs at darcs.net
Sun May 30 18:35:40 UTC 2021


Ben Franksen <ben.franksen at online.de> added the comment:

> Now, the way the above patch "fixes" writeFileUsingCache is by adding
> more side-effects to fetchFileUsingCachePrivate.

On closer inspection this statement is incorrect. What fixes the bug is
this hunk

    hunk ./src/Darcs/Util/Cache.hs 499
    -    _ <- fetchFileUsingCachePrivate LocalOnly (Ca cache) subdir hash
    +    debugMessage $ "writeFileUsingCache "++hash
    +    (fn, _) <- fetchFileUsingCachePrivate LocalOnly (Ca cache)
subdir hash
    +    mapM_ (tryLinking fn hash subdir) cache

which is inside writeFileUsingCache.

What happens is that fetchFileUsingCache succeeds with no side-effect
i.e. no hard-linking; we merely get the file content. Then, if the file
exists in the same file system, the hard linking succeeds and we are
done. If we are on a different file system, the hard link fails, which
means we enter the wfuc exception handler, where we do an actual write,
using the *first* writable location i.e. the local repo; afterwards we
again try to link with the cache, which fails, but this is no problem
since it is entirely optional, and thus the failure is silently ignored.

Before the patch, fetchFileUsingCache succeeded in the same way, but
then we returned without trying to link, so we never actually made sure
the file exists in our local repo.

So the way the patch fixes the issue is somewhat roundabout, but it does
*not* rely on side-effects of fetchFileUsingCache.

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/issue2677>
__________________________________


More information about the darcs-devel mailing list