File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -120,10 +120,18 @@ async def _ensure_typst_executable(self) -> None:
120120 async def _download_typst_executable (self ) -> None :
121121 if not Config .typst_archive_url :
122122 raise ValueError ("Trying to download Typst but the archive URL isn't set" )
123+ if not Config .typst_archive_sha256 :
124+ raise ValueError ("Trying to download Typst but the archive hash isn't set" )
123125 async with self .bot .http_session .get (
124126 Config .typst_archive_url , raise_for_status = True
125127 ) as response :
126128 arc_data = await response .read ()
129+ digest = hashlib .sha256 (arc_data ).hexdigest ()
130+ if digest != Config .typst_archive_sha256 :
131+ raise ValueError (
132+ f"Retrieved archive doesn't match hash { Config .typst_archive_sha256 } ; "
133+ f"instead got file with size { len (arc_data )} and hash { digest } "
134+ )
127135 log .info ("Retrieved Typst archive, unpacking" )
128136 typst_executable = archive_retrieve_file (
129137 arc_data ,
You can’t perform that action at this time.
0 commit comments