##// END OF EJS Templates
vfs: add "notindexed" argument to invoke "ensuredir" with it in write mode...
FUJIWARA Katsunori -
r23370:46265d0f default
parent child Browse files
Show More
@@ -197,9 +197,16 b' class abstractvfs(object):'
197 raise
197 raise
198 return []
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 self.open = self.__call__
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 def read(self, path):
211 def read(self, path):
205 fp = self(path, 'rb')
212 fp = self(path, 'rb')
@@ -345,7 +352,14 b' class vfs(abstractvfs):'
345 return
352 return
346 os.chmod(name, self.createmode & 0666)
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 if self._audit:
363 if self._audit:
350 r = util.checkosfilename(path)
364 r = util.checkosfilename(path)
351 if r:
365 if r:
@@ -363,7 +377,7 b' class vfs(abstractvfs):'
363 # to a directory. Let the posixfile() call below raise IOError.
377 # to a directory. Let the posixfile() call below raise IOError.
364 if basename:
378 if basename:
365 if atomictemp:
379 if atomictemp:
366 util.ensuredirs(dirname, self.createmode)
380 util.ensuredirs(dirname, self.createmode, notindexed)
367 return util.atomictempfile(f, mode, self.createmode)
381 return util.atomictempfile(f, mode, self.createmode)
368 try:
382 try:
369 if 'w' in mode:
383 if 'w' in mode:
@@ -381,7 +395,7 b' class vfs(abstractvfs):'
381 if e.errno != errno.ENOENT:
395 if e.errno != errno.ENOENT:
382 raise
396 raise
383 nlink = 0
397 nlink = 0
384 util.ensuredirs(dirname, self.createmode)
398 util.ensuredirs(dirname, self.createmode, notindexed)
385 if nlink > 0:
399 if nlink > 0:
386 if self._trustnlink is None:
400 if self._trustnlink is None:
387 self._trustnlink = nlink > 1 or util.checknlink(f)
401 self._trustnlink = nlink > 1 or util.checknlink(f)
@@ -1088,15 +1088,20 b' def makedirs(name, mode=None, notindexed'
1088 if mode is not None:
1088 if mode is not None:
1089 os.chmod(name, mode)
1089 os.chmod(name, mode)
1090
1090
1091 def ensuredirs(name, mode=None):
1091 def ensuredirs(name, mode=None, notindexed=False):
1092 """race-safe recursive directory creation"""
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 if os.path.isdir(name):
1098 if os.path.isdir(name):
1094 return
1099 return
1095 parent = os.path.dirname(os.path.abspath(name))
1100 parent = os.path.dirname(os.path.abspath(name))
1096 if parent != name:
1101 if parent != name:
1097 ensuredirs(parent, mode)
1102 ensuredirs(parent, mode, notindexed)
1098 try:
1103 try:
1099 os.mkdir(name)
1104 makedir(name, notindexed)
1100 except OSError, err:
1105 except OSError, err:
1101 if err.errno == errno.EEXIST and os.path.isdir(name):
1106 if err.errno == errno.EEXIST and os.path.isdir(name):
1102 # someone else seems to have won a directory creation race
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