Skip to content

Commit

Permalink
Merge pull request #4391 from wasmerio/fix-for-cached-modules
Browse files Browse the repository at this point in the history
Fixed an issue where the caching compiled modules were not saving properly
  • Loading branch information
syrusakbary authored Jan 8, 2024
2 parents a1f2b27 + 9bc286c commit e83428e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions lib/wasix/src/runtime/module_cache/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ impl ModuleCache for FileSystemCache {
}
Err(e) => {
tracing::debug!(
%key,
path=%path.display(),
error=&e as &dyn std::error::Error,
"Deleting the cache file because the artifact couldn't be deserialized",
);
%key,
path=%path.display(),
error=&e as &dyn std::error::Error,
"Deleting the cache file because the artifact couldn't be deserialized",
);

if let Err(e) = std::fs::remove_file(&path) {
tracing::warn!(
%key,
path=%path.display(),
error=&e as &dyn std::error::Error,
"Unable to remove the corrupted cache file",
);
%key,
path=%path.display(),
error=&e as &dyn std::error::Error,
"Unable to remove the corrupted cache file",
);
}

Err(e)
Expand Down Expand Up @@ -131,10 +131,11 @@ impl ModuleCache for FileSystemCache {
.await
.unwrap()?;

if let Err(error) = tokio::io::BufWriter::new(&mut file)
.write_all(&serialized)
.await
{
let mut writer = tokio::io::BufWriter::new(&mut file);
if let Err(error) = writer.write_all(&serialized).await {
return Err(CacheError::FileWrite { path, error });
}
if let Err(error) = writer.flush().await {
return Err(CacheError::FileWrite { path, error });
}

Expand Down

0 comments on commit e83428e

Please sign in to comment.