~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/hashcache.py

[merge] jam-integration 1512, includes Storage changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
from bzrlib.errors import BzrError
39
39
 
40
40
 
 
41
FP_MTIME_COLUMN = 1
 
42
FP_CTIME_COLUMN = 2
41
43
FP_MODE_COLUMN = 5
42
44
 
43
45
def _fingerprint(abspath):
175
177
            raise BzrError("file %r: unknown file stat mode: %o"%(abspath,mode))
176
178
 
177
179
        now = int(time.time())
178
 
        if file_fp[1] >= now or file_fp[2] >= now:
 
180
        if file_fp[FP_MTIME_COLUMN] >= now or file_fp[FP_CTIME_COLUMN] >= now:
179
181
            # changed too recently; can't be cached.  we can
180
182
            # return the result and it could possibly be cached
181
183
            # next time.
 
184
            #
 
185
            # the point is that we only want to cache when we are sure that any
 
186
            # subsequent modifications of the file can be detected.  If a
 
187
            # modification neither changes the inode, the device, the size, nor
 
188
            # the mode, then we can only distinguish it by time; therefore we
 
189
            # need to let sufficient time elapse before we may cache this entry
 
190
            # again.  If we didn't do this, then, for example, a very quick 1
 
191
            # byte replacement in the file might go undetected.
182
192
            self.danger_count += 1 
183
193
            if cache_fp:
184
194
                self.removed_count += 1