Reuse session-verified source versions in native source maps
This commit is contained in:
1 parent
225736ce80
commit
0a21eb27a7
5 files changed
+68
-9
No files matched your search
@@ -196,6 +196,13 @@ impl SourceMap {
|
||||
pub fn from_revision(
|
||||
revision: &RevisionExecution,
|
||||
pages: &[DisplayList],
|
||||
) -> Result<Self, String> {
|
||||
Self::from_revision_checked(revision, pages, true)
|
||||
}
|
||||
pub(crate) fn from_revision_checked(
|
||||
revision: &RevisionExecution,
|
||||
pages: &[DisplayList],
|
||||
verify_source_hashes: bool,
|
||||
) -> Result<Self, String> {
|
||||
let execution = &revision.execution;
|
||||
if revision.source_versions.len() != execution.sources.len() {
|
||||
@@ -208,7 +215,8 @@ impl SourceMap {
|
||||
.enumerate()
|
||||
.map(|(id, (file, version))| {
|
||||
if version.bytes != file.data.len() as u64
|
||||
|| version.sha256 != format!("{:x}", Sha256::digest(&file.data))
|
||||
|| (verify_source_hashes
|
||||
&& version.sha256 != format!("{:x}", Sha256::digest(&file.data)))
|
||||
{
|
||||
return Err(format!("source map version mismatch for source {id}"));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user