Skip to content

Commit 6aa0345

Browse files
committed
Merge branch 'main' into watch-close
2 parents 0edac5c + 6d8541b commit 6aa0345

File tree

7 files changed

+72
-28
lines changed

7 files changed

+72
-28
lines changed

.github/workflows/ci.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# - x86_64-unknown-netbsd
4747
steps:
4848
- name: Checkout
49-
uses: actions/checkout@v4
49+
uses: actions/checkout@v5
5050
with:
5151
submodules: recursive
5252

@@ -83,7 +83,7 @@ jobs:
8383
- armv7-linux-androideabi
8484
steps:
8585
- name: Checkout
86-
uses: actions/checkout@v4
86+
uses: actions/checkout@v5
8787

8888
- name: Set up Rust
8989
uses: dtolnay/rust-toolchain@stable
@@ -93,7 +93,7 @@ jobs:
9393
run: rustup target add ${{ matrix.target }}
9494

9595
- name: Setup Java
96-
uses: actions/setup-java@v4
96+
uses: actions/setup-java@v5
9797
with:
9898
distribution: 'temurin'
9999
java-version: '17'
@@ -127,7 +127,7 @@ jobs:
127127
- i686-unknown-linux-gnu
128128
steps:
129129
- name: Checkout
130-
uses: actions/checkout@v4
130+
uses: actions/checkout@v5
131131
with:
132132
submodules: recursive
133133

@@ -153,7 +153,7 @@ jobs:
153153
RUSTC_WRAPPER: "sccache"
154154
SCCACHE_GHA_ENABLED: "on"
155155
steps:
156-
- uses: actions/checkout@v4
156+
- uses: actions/checkout@v5
157157
with:
158158
fetch-depth: 0
159159
- name: Install sccache
@@ -185,7 +185,7 @@ jobs:
185185
RUSTC_WRAPPER: "sccache"
186186
SCCACHE_GHA_ENABLED: "on"
187187
steps:
188-
- uses: actions/checkout@v4
188+
- uses: actions/checkout@v5
189189
- uses: dtolnay/rust-toolchain@stable
190190
with:
191191
components: rustfmt
@@ -201,7 +201,7 @@ jobs:
201201
RUSTC_WRAPPER: "sccache"
202202
SCCACHE_GHA_ENABLED: "on"
203203
steps:
204-
- uses: actions/checkout@v4
204+
- uses: actions/checkout@v5
205205
- uses: dtolnay/rust-toolchain@master
206206
with:
207207
toolchain: nightly-2024-11-30
@@ -220,7 +220,7 @@ jobs:
220220
RUSTC_WRAPPER: "sccache"
221221
SCCACHE_GHA_ENABLED: "on"
222222
steps:
223-
- uses: actions/checkout@v4
223+
- uses: actions/checkout@v5
224224
- uses: dtolnay/rust-toolchain@stable
225225
with:
226226
components: clippy
@@ -247,7 +247,7 @@ jobs:
247247
RUSTC_WRAPPER: "sccache"
248248
SCCACHE_GHA_ENABLED: "on"
249249
steps:
250-
- uses: actions/checkout@v4
250+
- uses: actions/checkout@v5
251251
- uses: dtolnay/rust-toolchain@master
252252
with:
253253
toolchain: ${{ env.MSRV }}
@@ -263,7 +263,7 @@ jobs:
263263
name: cargo deny
264264
runs-on: ubuntu-latest
265265
steps:
266-
- uses: actions/checkout@v4
266+
- uses: actions/checkout@v5
267267
- uses: EmbarkStudios/cargo-deny-action@v2
268268
with:
269269
arguments: --workspace --all-features
@@ -274,6 +274,6 @@ jobs:
274274
timeout-minutes: 30
275275
runs-on: ubuntu-latest
276276
steps:
277-
- uses: actions/checkout@v4
277+
- uses: actions/checkout@v5
278278
- run: pip install --user codespell[toml]
279279
- run: codespell --ignore-words-list=ans,atmost,crate,inout,ratatui,ser,stayin,swarmin,worl --skip=CHANGELOG.md

.github/workflows/cleanup.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- name: Checkout
26-
uses: actions/checkout@v4
26+
uses: actions/checkout@v5
2727
with:
2828
ref: generated-docs-preview
2929
- name: Clean docs branch

.github/workflows/docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
PREVIEW_PATH: pr/${{ github.event.pull_request.number || inputs.pr_number }}/docs
3030

3131
steps:
32-
- uses: actions/checkout@v4
32+
- uses: actions/checkout@v5
3333
- uses: dtolnay/rust-toolchain@master
3434
with:
3535
toolchain: nightly-2024-11-30

.github/workflows/flaky.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
echo TESTS_RESULT=$result
6060
echo "TESTS_RESULT=$result" >>"$GITHUB_ENV"
6161
- name: download nextest reports
62-
uses: actions/download-artifact@v4
62+
uses: actions/download-artifact@v5
6363
with:
6464
pattern: libtest_run_${{ github.run_number }}-${{ github.run_attempt }}-*
6565
merge-multiple: true

.github/workflows/tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
RUSTC_WRAPPER: "sccache"
5555
steps:
5656
- name: Checkout
57-
uses: actions/checkout@v4
57+
uses: actions/checkout@v5
5858
with:
5959
ref: ${{ inputs.git-ref }}
6060

@@ -161,7 +161,7 @@ jobs:
161161
RUSTC_WRAPPER: "sccache"
162162
steps:
163163
- name: Checkout
164-
uses: actions/checkout@v4
164+
uses: actions/checkout@v5
165165
with:
166166
ref: ${{ inputs.git-ref }}
167167

src/store/fs.rs

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ use entity_manager::{EntityManagerState, SpawnArg};
9393
use entry_state::{DataLocation, OutboardLocation};
9494
use gc::run_gc;
9595
use import::{ImportEntry, ImportSource};
96-
use irpc::channel::mpsc;
96+
use irpc::{channel::mpsc, RpcMessage};
9797
use meta::list_blobs;
9898
use n0_future::{future::yield_now, io};
9999
use nested_enum_utils::enum_conversions;
@@ -1263,9 +1263,12 @@ 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+
let res = reflink_or_copy_with_progress(&source_path, &target, size, tx).await?;
1267+
trace!(
1268+
"exported {} to {}, {res:?}",
1269+
source_path.display(),
1270+
target.display()
1271+
);
12691272
}
12701273
ExportMode::TryReference => {
12711274
match std::fs::rename(&source_path, &target) {
@@ -1295,11 +1298,50 @@ async fn export_path_impl(
12951298
Ok(())
12961299
}
12971300

1298-
async fn copy_with_progress(
1301+
trait CopyProgress: RpcMessage {
1302+
fn from_offset(offset: u64) -> Self;
1303+
}
1304+
1305+
impl CopyProgress for ExportProgressItem {
1306+
fn from_offset(offset: u64) -> Self {
1307+
ExportProgressItem::CopyProgress(offset)
1308+
}
1309+
}
1310+
1311+
impl CopyProgress for AddProgressItem {
1312+
fn from_offset(offset: u64) -> Self {
1313+
AddProgressItem::CopyProgress(offset)
1314+
}
1315+
}
1316+
1317+
#[derive(Debug)]
1318+
enum CopyResult {
1319+
Reflinked,
1320+
Copied,
1321+
}
1322+
1323+
async fn reflink_or_copy_with_progress(
1324+
from: impl AsRef<Path>,
1325+
to: impl AsRef<Path>,
1326+
size: u64,
1327+
tx: &mut mpsc::Sender<impl CopyProgress>,
1328+
) -> io::Result<CopyResult> {
1329+
let from = from.as_ref();
1330+
let to = to.as_ref();
1331+
if reflink_copy::reflink(from, to).is_ok() {
1332+
return Ok(CopyResult::Reflinked);
1333+
}
1334+
let source = fs::File::open(from)?;
1335+
let mut target = fs::File::create(to)?;
1336+
copy_with_progress(source, size, &mut target, tx).await?;
1337+
Ok(CopyResult::Copied)
1338+
}
1339+
1340+
async fn copy_with_progress<T: CopyProgress>(
12991341
file: impl ReadAt,
13001342
size: u64,
13011343
target: &mut impl Write,
1302-
tx: &mut mpsc::Sender<ExportProgressItem>,
1344+
tx: &mut mpsc::Sender<T>,
13031345
) -> io::Result<()> {
13041346
let mut offset = 0;
13051347
let mut buf = vec![0u8; 1024 * 1024];
@@ -1308,7 +1350,7 @@ async fn copy_with_progress(
13081350
let buf: &mut [u8] = &mut buf[..remaining];
13091351
file.read_exact_at(offset, buf)?;
13101352
target.write_all(buf)?;
1311-
tx.try_send(ExportProgressItem::CopyProgress(offset))
1353+
tx.try_send(T::from_offset(offset))
13121354
.await
13131355
.map_err(|_e| io::Error::other(""))?;
13141356
yield_now().await;

src/store/fs/import.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use crate::{
4343
},
4444
},
4545
store::{
46+
fs::reflink_or_copy_with_progress,
4647
util::{MemOrFile, DD},
4748
IROH_BLOCK_SIZE,
4849
},
@@ -491,11 +492,12 @@ async fn import_path_impl(
491492
let temp_path = options.path.temp_file_name();
492493
// todo: if reflink works, we don't need progress.
493494
// But if it does not, it might take a while and we won't get progress.
494-
if reflink_copy::reflink_or_copy(&path, &temp_path)?.is_none() {
495-
trace!("reflinked {} to {}", path.display(), temp_path.display());
496-
} else {
497-
trace!("copied {} to {}", path.display(), temp_path.display());
498-
}
495+
let res = reflink_or_copy_with_progress(&path, &temp_path, size, tx).await?;
496+
trace!(
497+
"imported {} to {}, {res:?}",
498+
path.display(),
499+
temp_path.display()
500+
);
499501
// copy from path to temp_path
500502
let file = OpenOptions::new().read(true).open(&temp_path)?;
501503
tx.send(AddProgressItem::CopyDone)

0 commit comments

Comments
 (0)