Show More
@@ -451,6 +451,8 b' class fncache(object):' | |||||
451 | self.vfs = vfs |
|
451 | self.vfs = vfs | |
452 | self.entries = None |
|
452 | self.entries = None | |
453 | self._dirty = False |
|
453 | self._dirty = False | |
|
454 | # set of new additions to fncache | |||
|
455 | self.addls = set() | |||
454 |
|
456 | |||
455 | def _load(self): |
|
457 | def _load(self): | |
456 | '''fill the entries from the fncache file''' |
|
458 | '''fill the entries from the fncache file''' | |
@@ -479,17 +481,28 b' class fncache(object):' | |||||
479 | fp.write(encodedir('\n'.join(self.entries) + '\n')) |
|
481 | fp.write(encodedir('\n'.join(self.entries) + '\n')) | |
480 | fp.close() |
|
482 | fp.close() | |
481 | self._dirty = False |
|
483 | self._dirty = False | |
|
484 | if self.addls: | |||
|
485 | # if we have just new entries, let's append them to the fncache | |||
|
486 | tr.addbackup('fncache') | |||
|
487 | fp = self.vfs('fncache', mode='ab', atomictemp=True) | |||
|
488 | if self.addls: | |||
|
489 | fp.write(encodedir('\n'.join(self.addls) + '\n')) | |||
|
490 | fp.close() | |||
|
491 | self.entries = None | |||
|
492 | self.addls = set() | |||
482 |
|
493 | |||
483 | def add(self, fn): |
|
494 | def add(self, fn): | |
484 | if self.entries is None: |
|
495 | if self.entries is None: | |
485 | self._load() |
|
496 | self._load() | |
486 | if fn not in self.entries: |
|
497 | if fn not in self.entries: | |
487 |
self. |
|
498 | self.addls.add(fn) | |
488 | self.entries.add(fn) |
|
|||
489 |
|
499 | |||
490 | def remove(self, fn): |
|
500 | def remove(self, fn): | |
491 | if self.entries is None: |
|
501 | if self.entries is None: | |
492 | self._load() |
|
502 | self._load() | |
|
503 | if fn in self.addls: | |||
|
504 | self.addls.remove(fn) | |||
|
505 | return | |||
493 | try: |
|
506 | try: | |
494 | self.entries.remove(fn) |
|
507 | self.entries.remove(fn) | |
495 | self._dirty = True |
|
508 | self._dirty = True | |
@@ -497,6 +510,8 b' class fncache(object):' | |||||
497 | pass |
|
510 | pass | |
498 |
|
511 | |||
499 | def __contains__(self, fn): |
|
512 | def __contains__(self, fn): | |
|
513 | if fn in self.addls: | |||
|
514 | return True | |||
500 | if self.entries is None: |
|
515 | if self.entries is None: | |
501 | self._load() |
|
516 | self._load() | |
502 | return fn in self.entries |
|
517 | return fn in self.entries | |
@@ -504,7 +519,7 b' class fncache(object):' | |||||
504 | def __iter__(self): |
|
519 | def __iter__(self): | |
505 | if self.entries is None: |
|
520 | if self.entries is None: | |
506 | self._load() |
|
521 | self._load() | |
507 | return iter(self.entries) |
|
522 | return iter(self.entries | self.addls) | |
508 |
|
523 | |||
509 | class _fncachevfs(vfsmod.abstractvfs, vfsmod.proxyvfs): |
|
524 | class _fncachevfs(vfsmod.abstractvfs, vfsmod.proxyvfs): | |
510 | def __init__(self, vfs, fnc, encode): |
|
525 | def __init__(self, vfs, fnc, encode): | |
@@ -580,6 +595,7 b' class fncachestore(basicstore):' | |||||
580 |
|
595 | |||
581 | def invalidatecaches(self): |
|
596 | def invalidatecaches(self): | |
582 | self.fncache.entries = None |
|
597 | self.fncache.entries = None | |
|
598 | self.fncache.addls = set() | |||
583 |
|
599 | |||
584 | def markremoved(self, fn): |
|
600 | def markremoved(self, fn): | |
585 | self.fncache.remove(fn) |
|
601 | self.fncache.remove(fn) |
General Comments 0
You need to be logged in to leave comments.
Login now