Changeset 161 for trunk/source/pyhesiodfs
- Timestamp:
- 12/22/08 13:52:56 (16 years ago)
- Files:
-
- trunk/source/pyhesiodfs/pyHesiodFS.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/source/pyhesiodfs/pyHesiodFS.py
r160 r161 10 10 # 11 11 12 import sys, os, stat, errno 12 import sys, os, stat, errno, time 13 13 from syslog import * 14 14 import fuse … … 40 40 print 'defaultdict(%s, %s)' % (self.default_factory, 41 41 super(defaultdict, self).__str__()) 42 42 43 class negcache(dict): 44 """ 45 A set-like object that automatically expunges entries after 46 they're been there for a certain amount of time. 47 48 This only supports add, remove, and __contains__ 49 """ 50 51 def __init__(self, cache_time): 52 self.cache_time = cache_time 53 54 def add(self, obj): 55 self[obj] = time.time() 56 57 def remove(self, obj): 58 del self[obj] 59 60 def __contains__(self, k): 61 if super(negcache, self).__contains__(k): 62 if self[k] + self.cache_time > time.time(): 63 return True 64 else: 65 del self[k] 66 return False 67 43 68 new_fuse = hasattr(fuse, '__version__') 44 69 … … 91 116 self.fuse_args.add("fsname", "pyHesiodFS") 92 117 self.mounts = defaultdict(dict) 118 119 # Cache deletions for 10 seconds - should give people time to 120 # make a new symlink 121 self.negcache = negcache(10) 93 122 94 123 def _user(self): … … 105 134 st.st_size = len(hello_str) 106 135 elif '/' not in path[1:]: 107 if self.findLocker(path[1:]):136 if path[1:] not in self.negcache and self.findLocker(path[1:]): 108 137 st.st_mode = stat.S_IFLNK | 0777 109 138 st.st_uid = self._user() … … 183 212 elif '/' not in path[1:]: 184 213 del self.mounts[self._user()][path[1:]] 214 self.negcache.add(path[1:]) 185 215 else: 186 216 return -errno.EPERM