[Tilecache] make dir error
Christopher Schmidt
crschmidt at metacarta.com
Thu Apr 10 11:47:31 EDT 2008
On Thu, Apr 10, 2008 at 05:32:33PM +0200, Fredrik Lundh wrote:
> > Agreed. I keep thinking I've already done this, but never get around to
> > it. I'll take a patch...
>
> The patch below should work, I think (only briefly tested).
>
> </F>
My concern with this path is that TileCache makes pretty deep
directories: imagining that you have:
os.makedirs(
/0/0/0/0/0/0/
)
and:
os.makedirs(
/0/0/0/0/0/1/
)
And they both get called at the same time, you could get a condition
where:
1: /0 is created
2: tries to make /0, bails
1. Successfully makes /0/0/0/0/0/0 whatever
2. Has no /1 directory, writing file fails
Am I wrong here, or is this a possibility? If it is a possibility, is it
worth trying to fix? Should the exception handler catch the exception,
and try again?
-- Chris
> --- Disk.py.bak Thu Apr 10 17:27:09 2008
> +++ Disk.py Thu Apr 10 17:20:35 2008
> @@ -1,7 +1,7 @@
> # BSD Licensed, Copyright (c) 2006-2007 MetaCarta, Inc.
>
> from TileCache.Cache import Cache
> -import sys, os, time
> +import sys, os, time, errno
>
> class Disk (Cache):
> def __init__ (self, base = None, umask = '002', **kwargs):
> @@ -21,7 +21,11 @@
>
> def makedirs(self, path):
> old_umask = os.umask(self.umask)
> - os.makedirs(path)
> + try:
> + os.makedirs(path)
> + except OSError, e:
> + if e.errno != errno.EEXIST:
> + raise
> os.umask(old_umask)
>
> def access(self, path, type='read'):
> _______________________________________________
> Tilecache mailing list
> Tilecache at openlayers.org
> http://openlayers.org/mailman/listinfo/tilecache
--
Christopher Schmidt
MetaCarta
More information about the Tilecache
mailing list