Skip to content

Commit

Permalink
Useuse inspect data for hash and file size on startup
Browse files Browse the repository at this point in the history
Thanks, @fgregg

Closes #1834
  • Loading branch information
fgregg authored Oct 6, 2022
1 parent bbf33a7 commit eff1124
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions datasette/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ def __init__(
self._read_connection = None
self._write_connection = None
if not self.is_mutable and not self.is_memory:
p = Path(path)
self.hash = inspect_hash(p)
self.cached_size = p.stat().st_size
if self.ds.inspect_data and self.ds.inspect_data.get(self.name):
self.hash = self.ds.inspect_data[self.name]["hash"]
self.cached_size = self.ds.inspect_data[self.name]["size"]
else:
p = Path(path)
self.hash = inspect_hash(p)
self.cached_size = p.stat().st_size

@property
def cached_table_counts(self):
Expand Down

0 comments on commit eff1124

Please sign in to comment.