/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to cache_manager.py

[r=mbp] Remove duplicate definition of cache_manager._Cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
            shutil.rmtree(self.tempdir)
62
62
 
63
63
 
64
 
class _Cleanup(object):
65
 
    """This class makes sure we clean up when CacheManager goes away.
66
 
 
67
 
    We use a helper class to ensure that we are never in a refcycle.
68
 
    """
69
 
 
70
 
    def __init__(self, disk_blobs):
71
 
        self.disk_blobs = disk_blobs
72
 
        self.tempdir = None
73
 
        self.small_blobs = None
74
 
 
75
 
    def __del__(self):
76
 
        self.finalize()
77
 
 
78
 
    def finalize(self):
79
 
        if self.disk_blobs is not None:
80
 
            for info in self.disk_blobs.itervalues():
81
 
                if info[-1] is not None:
82
 
                    os.unlink(info[-1])
83
 
            self.disk_blobs = None
84
 
        if self.small_blobs is not None:
85
 
            self.small_blobs.close()
86
 
            self.small_blobs = None
87
 
        if self.tempdir is not None:
88
 
            shutil.rmtree(self.tempdir)
89
 
 
90
 
 
91
64
class CacheManager(object):
92
65
 
93
66
    _small_blob_threshold = 25*1024