Skip to content

Commit 0374408

Browse files
committed
Use reflink_or_copy for export as well
1 parent ee3e710 commit 0374408

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/store/fs.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,9 +1263,18 @@ async fn export_path_impl(
12631263
}
12641264
MemOrFile::File((source_path, size)) => match mode {
12651265
ExportMode::Copy => {
1266-
let source = fs::File::open(&source_path)?;
1267-
let mut target = fs::File::create(&target)?;
1268-
copy_with_progress(&source, size, &mut target, tx).await?
1266+
tx.try_send(ExportProgressItem::CopyProgress(0))
1267+
.await
1268+
.map_err(|_e| io::Error::other(""))?;
1269+
let written = reflink_copy::reflink_or_copy(&source_path, &target)?;
1270+
if let Some(written) = written {
1271+
if written != size {
1272+
return Err(io::Error::other(format!(
1273+
"wrote {written} bytes, expected {size}",
1274+
))
1275+
.into());
1276+
}
1277+
}
12691278
}
12701279
ExportMode::TryReference => {
12711280
match std::fs::rename(&source_path, &target) {

0 commit comments

Comments
 (0)