Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where the caching compiled modules were not saving properly #4391

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading