Mercurial > public > mercurial-scm > hg
diff mercurial/store.py @ 50809:30381812708d stable
fncache: fix a bug that corrupts the fncache after transaction rollback
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Thu, 13 Jul 2023 19:36:43 +0100 |
parents | 0452af304808 |
children | 18c8c18993f0 |
line wrap: on
line diff
--- a/mercurial/store.py Thu Jul 13 19:26:45 2023 +0100 +++ b/mercurial/store.py Thu Jul 13 19:36:43 2023 +0100 @@ -1093,12 +1093,13 @@ ): # do not trigger a fncache load when adding a file that already is # known to exist. - notload = self.fncache.entries is None and self.vfs.exists(encoded) - if notload and b'r+' in mode and not self.vfs.stat(encoded).st_size: - # when appending to an existing file, if the file has size zero, - # it should be considered as missing. Such zero-size files are - # the result of truncation when a transaction is aborted. - notload = False + notload = self.fncache.entries is None and ( + # if the file has size zero, it should be considered as missing. + # Such zero-size files are the result of truncation when a + # transaction is aborted. + self.vfs.exists(encoded) + and self.vfs.stat(encoded).st_size + ) if not notload: self.fncache.add(path) return self.vfs(encoded, mode, *args, **kw)