fix: fall back to GIO on destination open failure for MTP copies

* fix: fall back to GIO on destination open failure for MTP copies
* Preserve error source chain in non-gvfs open failure path
This commit is contained in:
Joel 2026-07-16 00:12:17 +05:30 • committed by GitHub
parent 5278c67957
commit a93fc1d9ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -453,7 +453,7 @@ impl Op {
}
}
let (from_file, metadata, to_file) = cosmic::iced::futures::join!(
let (from_file_open_result, metadata, to_file_open_result) = cosmic::iced::futures::join!(
async {
compio::fs::OpenOptions::new()
.read(true)
@ -469,12 +469,28 @@ impl Op {
.write(true)
.open(&self.to)
.await
.with_context(|| format!("failed to open {} for writing", self.to.display()))
}
);
let from_file = from_file?;
let mut to_file = to_file?;
let from_file = from_file_open_result?;
let mut to_file = match to_file_open_result {
Ok(file) => file,
#[cfg(not(feature = "gvfs"))]
Err(why) => {
_ = from_file.close().await;
return Err(why).with_context(|| format!("failed to open {} for writing", self.to.display())).map_err(Into::into);
}
#[cfg(feature = "gvfs")]
Err(_why) => {
_ = from_file.close().await;
return self
.gio_file_copy(ctx, progress)
.await
.map(|()| true)
.map_err(Into::into);
}
};
progress.total_bytes = metadata.as_ref().map(|m| m.len());
(ctx.on_progress)(self, &progress);