[darcs-users] Fwd: [patch72] resolve issue1624 break global cache up into subdirectories

Luca Molteni volothamp at gmail.com
Fri Jan 8 09:50:17 UTC 2010


L.M.



---------- Forwarded message ----------
From: Luca Molteni <volothamp at gmail.com>
Date: 2009/12/28
Subject: Re: [patch72] resolve issue1624 break global cache up into
subdirectories
To: darcs-users at darcs.net
Cc: kowey at darcs.net, me at mornfall.net, tux_rocker at reinier.de


2009/11/29 Reinier Lamers <tux_rocker at reinier.de>:

> What happens with old caches that still use the older names? Aren't they made useless by this change?

The old cache will stay in the same position as before. This patch
doesn't delete any files. From now on, the new cache will be read
instead of the old one.
You can manually delete the cache, or leave it as it is.
Maybe in the a new release we can force the deletion of the old files.


>> hunk ./src/Darcs/Repository/Cache.hs 168
>>
>>  data FromWhere = LocalOnly | Anywhere deriving ( Eq )
>>
>> +createBucket :: String -> IO ()
>> +createBucket s = createDirectoryIfMissing True (takeDirectory s)
>> +
>
> Why do you change the first argument of createDirectoryIfMissing to True?

This is the function that creates the directories of the cache.
We create a subdir for each group and we have to create the parent
cache directory too. This is the meaning of True in
createDirectoryIfMissing.

The createBucket function is called before writing in the cache. If
you don't create the directory, you can't write in it.

>> hunk ./src/Darcs/Repository/Cache.hs 206
>>                   return (fn c, x)
>>                `catchall` do (fname,x) <- ffuc cs
>>                              do createCache c subdir
>> +                               createBucket (fn c)
>>                                 createLink fname (fn c)
>>                                 return (fn c, x)
>>                               `catchall`
>
> Why is this necessary?
>
>> hunk ./src/Darcs/Repository/Cache.hs 247
>>      where hash = cacheHash ps
>>            wfuc (c:cs) | not $ writable c = wfuc cs
>>                        | otherwise = do createCache c subdir
>> +                                       createBucket (fn c)
>>                                         write compr (fn c) ps -- FIXME: create links in caches
>>                                         return hash
>>            wfuc [] = debugFail $ "No location to write file `" ++ (hashedDir subdir) ++"/"++hash ++ "'"
>
> Bye,
> Reinier


The problem I found with this implementation is that the folder where
there the cache is is copied if you take the repository and copy it to
another machine, instead of using "darcs get".

I think this may be a side effect of changing createDirectoryIfMissing
to True. Now it creates the whole tree if it doesn't exixts, leading
to very strange results (I found a unix path with the darcs cache on
my windows machine :|).

I'm still not sure about that, I think I'll be able to investigate
that in these days.

Steps to reproduce that:

Copy a repository from a Unix machine using cp

Modify your repository on a windows machine and record a patch.

See if something bad happened (strange folders in your machine).


Bye,

L.M.


More information about the darcs-users mailing list