Batch draft transcripts and reuse verified source versions
This commit is contained in:
1 parent
373204a8d8
commit
c6b5c9ed56
4 files changed
+108
-47
No files matched your search
@@ -109,9 +109,12 @@ impl SourceProvider for RecordingHost<'_> {
|
||||
}
|
||||
fn read(&mut self, name: &str, from: &str) -> Result<SourceFile, String> {
|
||||
let (name, from) = (name.to_owned(), from.to_owned());
|
||||
call!(self, read(&name, &from); |result| {
|
||||
result.as_ref().map(|file| (file.name.clone(), digest(&file.data))).map_err(Clone::clone)
|
||||
})
|
||||
self.record(
|
||||
"read",
|
||||
move |files| files.read_versioned_source(&name, &from),
|
||||
|result| result.as_ref().map(|(_, version)| version.clone()).map_err(Clone::clone),
|
||||
)
|
||||
.map(|(source, _)| source)
|
||||
}
|
||||
fn resource(
|
||||
&mut self,
|
||||
@@ -312,6 +315,7 @@ impl SourceProvider for RecordingHost<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn digest(bytes: &[u8]) -> String {
|
||||
use sha2::{Digest, Sha256};
|
||||
format!("{:x}", Sha256::digest(bytes))
|
||||
|
||||
Reference in new issue
Block a user