changeset 5611:ad60b3570553

MoinMoin.util.filesys: disable usage of dircache, deprecate dc* functions (details below) The dircache stdlib module can't work for fast updates of directories. It uses an mtime check on the directory to determine whether it has changed and returns cached stuff if it thinks it didn't change. This will just go wrong, if you update the directory faster than directory mtime granularity of the filesystem (the mtime might not change then). Thus, for ext3, it breaks if you update faster than 1s (that broke some of our unit tests). For FAT32 we had found earlier that it is completely broken (IIRC because FAT32 does not support directory mtime). We had it disabled therefore completely on win32 platform. For now, the dc* functions are emitting DeprecationWarnings and either doing nothing or calling the uncached os.listdir() function. Next, we'll fix the callers and later, dc* will get removed completely.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 07 Mar 2010 20:10:29 +0100
parents 6f975bdd5adf
children cc15366f7b74
files MoinMoin/util/filesys.py
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/util/filesys.py	Sat Mar 06 22:43:34 2010 +0100
+++ b/MoinMoin/util/filesys.py	Sun Mar 07 20:10:29 2010 +0100
@@ -9,6 +9,7 @@
 
 import sys, os, shutil, time, errno, random
 from stat import S_ISDIR, ST_MODE, S_IMODE
+import warnings
 
 from MoinMoin import log
 logging = log.getLogger(__name__)
@@ -324,21 +325,29 @@
     def realPathCase(path):
         return None
 
-# dircache stuff seems to be broken on win32 (at least for FAT32, maybe NTFS)
-DCENABLED = 1 # set to 0 to disable dirchache usage
+# dircache stuff seems to be broken on win32 (at least for FAT32, maybe NTFS).
+# dircache stuff is also broken on POSIX if updates happen too fast (< 1s).
+DCENABLED = 0 # set to 0 to completely disable dircache usage
+
+# Note: usage of the dc* functions below is deprecated, they'll get removed soon.
+dc_deprecated = "dircache function calls (dcdisable,dclistdir,dcreset) are deprecated, please fix caller"
+
 def dcdisable():
+    warnings.warn(dc_deprecated, DeprecationWarning, stacklevel=2)
     global DCENABLED
     DCENABLED = 0
 
 import dircache
 
 def dclistdir(path):
+    warnings.warn(dc_deprecated, DeprecationWarning, stacklevel=2)
     if sys.platform == 'win32' or not DCENABLED:
         return os.listdir(path)
     else:
         return dircache.listdir(path)
 
 def dcreset():
+    warnings.warn(dc_deprecated, DeprecationWarning, stacklevel=2)
     if sys.platform == 'win32' or not DCENABLED:
         return
     else: