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