Show More
@@ -317,36 +317,36 b' class fncache(object):' | |||||
317 |
|
317 | |||
318 | def _load(self): |
|
318 | def _load(self): | |
319 | '''fill the entries from the fncache file''' |
|
319 | '''fill the entries from the fncache file''' | |
320 | self.entries = set() |
|
|||
321 | self._dirty = False |
|
320 | self._dirty = False | |
322 | try: |
|
321 | try: | |
323 | fp = self.opener('fncache', mode='rb') |
|
322 | fp = self.opener('fncache', mode='rb') | |
324 | except IOError: |
|
323 | except IOError: | |
325 | # skip nonexistent file |
|
324 | # skip nonexistent file | |
|
325 | self.entries = set() | |||
326 | return |
|
326 | return | |
|
327 | self.entries = set(map(decodedir, fp.read().splitlines())) | |||
|
328 | if '' in self.entries: | |||
|
329 | fp.seek(0) | |||
327 | for n, line in enumerate(fp): |
|
330 | for n, line in enumerate(fp): | |
328 | if (len(line) < 2) or (line[-1] != '\n'): |
|
331 | if not line.rstrip('\n'): | |
329 | t = _('invalid entry in fncache, line %s') % (n + 1) |
|
332 | t = _('invalid entry in fncache, line %s') % (n + 1) | |
330 | raise util.Abort(t) |
|
333 | raise util.Abort(t) | |
331 | self.entries.add(decodedir(line[:-1])) |
|
|||
332 | fp.close() |
|
334 | fp.close() | |
333 |
|
335 | |||
|
336 | def _write(self, files, atomictemp): | |||
|
337 | fp = self.opener('fncache', mode='wb', atomictemp=atomictemp) | |||
|
338 | if files: | |||
|
339 | fp.write('\n'.join(map(encodedir, files)) + '\n') | |||
|
340 | fp.close() | |||
|
341 | self._dirty = False | |||
|
342 | ||||
334 | def rewrite(self, files): |
|
343 | def rewrite(self, files): | |
335 | fp = self.opener('fncache', mode='wb') |
|
344 | self._write(files, False) | |
336 | for p in files: |
|
|||
337 | fp.write(encodedir(p) + '\n') |
|
|||
338 | fp.close() |
|
|||
339 | self.entries = set(files) |
|
345 | self.entries = set(files) | |
340 | self._dirty = False |
|
|||
341 |
|
346 | |||
342 | def write(self): |
|
347 | def write(self): | |
343 |
if |
|
348 | if self._dirty: | |
344 | return |
|
349 | self._write(self.entries, True) | |
345 | fp = self.opener('fncache', mode='wb', atomictemp=True) |
|
|||
346 | for p in self.entries: |
|
|||
347 | fp.write(encodedir(p) + '\n') |
|
|||
348 | fp.close() |
|
|||
349 | self._dirty = False |
|
|||
350 |
|
350 | |||
351 | def add(self, fn): |
|
351 | def add(self, fn): | |
352 | if self.entries is None: |
|
352 | if self.entries is None: |
General Comments 0
You need to be logged in to leave comments.
Login now