Show More
@@ -197,9 +197,16 b' class abstractvfs(object):' | |||
|
197 | 197 | raise |
|
198 | 198 | return [] |
|
199 | 199 | |
|
200 |
def open(self, path, mode="r", text=False, atomictemp=False |
|
|
200 | def open(self, path, mode="r", text=False, atomictemp=False, | |
|
201 | notindexed=False): | |
|
202 | '''Open ``path`` file, which is relative to vfs root. | |
|
203 | ||
|
204 | Newly created directories are marked as "not to be indexed by | |
|
205 | the content indexing service", if ``notindexed`` is specified | |
|
206 | for "write" mode access. | |
|
207 | ''' | |
|
201 | 208 | self.open = self.__call__ |
|
202 | return self.__call__(path, mode, text, atomictemp) | |
|
209 | return self.__call__(path, mode, text, atomictemp, notindexed) | |
|
203 | 210 | |
|
204 | 211 | def read(self, path): |
|
205 | 212 | fp = self(path, 'rb') |
@@ -345,7 +352,14 b' class vfs(abstractvfs):' | |||
|
345 | 352 | return |
|
346 | 353 | os.chmod(name, self.createmode & 0666) |
|
347 | 354 | |
|
348 |
def __call__(self, path, mode="r", text=False, atomictemp=False |
|
|
355 | def __call__(self, path, mode="r", text=False, atomictemp=False, | |
|
356 | notindexed=False): | |
|
357 | '''Open ``path`` file, which is relative to vfs root. | |
|
358 | ||
|
359 | Newly created directories are marked as "not to be indexed by | |
|
360 | the content indexing service", if ``notindexed`` is specified | |
|
361 | for "write" mode access. | |
|
362 | ''' | |
|
349 | 363 | if self._audit: |
|
350 | 364 | r = util.checkosfilename(path) |
|
351 | 365 | if r: |
@@ -363,7 +377,7 b' class vfs(abstractvfs):' | |||
|
363 | 377 | # to a directory. Let the posixfile() call below raise IOError. |
|
364 | 378 | if basename: |
|
365 | 379 | if atomictemp: |
|
366 | util.ensuredirs(dirname, self.createmode) | |
|
380 | util.ensuredirs(dirname, self.createmode, notindexed) | |
|
367 | 381 | return util.atomictempfile(f, mode, self.createmode) |
|
368 | 382 | try: |
|
369 | 383 | if 'w' in mode: |
@@ -381,7 +395,7 b' class vfs(abstractvfs):' | |||
|
381 | 395 | if e.errno != errno.ENOENT: |
|
382 | 396 | raise |
|
383 | 397 | nlink = 0 |
|
384 | util.ensuredirs(dirname, self.createmode) | |
|
398 | util.ensuredirs(dirname, self.createmode, notindexed) | |
|
385 | 399 | if nlink > 0: |
|
386 | 400 | if self._trustnlink is None: |
|
387 | 401 | self._trustnlink = nlink > 1 or util.checknlink(f) |
@@ -1088,15 +1088,20 b' def makedirs(name, mode=None, notindexed' | |||
|
1088 | 1088 | if mode is not None: |
|
1089 | 1089 | os.chmod(name, mode) |
|
1090 | 1090 | |
|
1091 | def ensuredirs(name, mode=None): | |
|
1092 |
"""race-safe recursive directory creation |
|
|
1091 | def ensuredirs(name, mode=None, notindexed=False): | |
|
1092 | """race-safe recursive directory creation | |
|
1093 | ||
|
1094 | Newly created directories are marked as "not to be indexed by | |
|
1095 | the content indexing service", if ``notindexed`` is specified | |
|
1096 | for "write" mode access. | |
|
1097 | """ | |
|
1093 | 1098 | if os.path.isdir(name): |
|
1094 | 1099 | return |
|
1095 | 1100 | parent = os.path.dirname(os.path.abspath(name)) |
|
1096 | 1101 | if parent != name: |
|
1097 | ensuredirs(parent, mode) | |
|
1102 | ensuredirs(parent, mode, notindexed) | |
|
1098 | 1103 | try: |
|
1099 |
|
|
|
1104 | makedir(name, notindexed) | |
|
1100 | 1105 | except OSError, err: |
|
1101 | 1106 | if err.errno == errno.EEXIST and os.path.isdir(name): |
|
1102 | 1107 | # someone else seems to have won a directory creation race |
General Comments 0
You need to be logged in to leave comments.
Login now