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.
--- 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):