Open rhizoome opened 2 months ago
Here is how I solved it for the time being:
diff --git a/crates/applesauce/src/threads/writer.rs b/crates/applesauce/src/threads/writer.rs
index 0a809630..89dfad7d 100644
--- a/crates/applesauce/src/threads/writer.rs
+++ b/crates/applesauce/src/threads/writer.rs
@@ -8,7 +8,8 @@ use std::io::{BufRead, BufReader, BufWriter, Seek, Write};
use std::os::fd::AsRawFd;
use std::os::macos::fs::MetadataExt;
use std::sync::Arc;
-use std::{cmp, io, ptr};
+use std::time::Duration;
+use std::{cmp, io, ptr, thread};
use tempfile::NamedTempFile;
pub(super) type Sender = crossbeam_channel::Sender<WorkItem>;
@@ -134,8 +135,13 @@ impl Handler {
if item.context.operation.verify {
let _entered = tracing::info_span!("verify").entered();
- let orig_file = Arc::get_mut(&mut item.file)
- .expect("Reader should drop file before finishing writing blocks, writer should have the only reference");
+ let orig_file = loop {
+ if let Some(file) = Arc::get_mut(&mut item.file) {
+ break file;
+ } else {
+ thread::sleep(Duration::from_millis(100));
+ }
+ };
let mut orig_file = BufReader::new(orig_file);
let mut new_file = BufReader::new(tmp_file.as_file_mut());
I get this panics from time to time on a Apple M1. Nothing ever broke, but it is kind of scary.