# HG changeset patch # User Pierre-Yves David # Date 1685327069 -7200 # Node ID 786443bd3bc1829b298d3a6b8899b106599dbc9d # Parent b59e0a4f692f4fe8aad3c829dc06a231757f764b store: cache the file_size when we get it from disk The point of caching `files` is to ensure consistency and avoiding redoing expensive work. So we cache the file_size once retrieved. diff -r b59e0a4f692f -r 786443bd3bc1 mercurial/store.py --- a/mercurial/store.py Sun May 28 03:46:48 2023 +0200 +++ b/mercurial/store.py Mon May 29 04:24:29 2023 +0200 @@ -578,12 +578,12 @@ is_volatile = attr.ib(default=False) def file_size(self, vfs): - if self._file_size is not None: - return self._file_size - try: - return vfs.stat(self.unencoded_path).st_size - except FileNotFoundError: - return 0 + if self._file_size is None: + try: + self._file_size = vfs.stat(self.unencoded_path).st_size + except FileNotFoundError: + self._file_size = 0 + return self._file_size def _gather_revlog(files_data):