Skip to content

Commit 6d0f4fa

Browse files
committed
libutil: Fix copyRecursive and use for nix flake clone
The use of sourceToSink is an unnecessary serialization bottleneck. While we are at it, fix the copyRecursive implementation to actually copy the whole directory. It wasn't used for anything prior, but now it has a use and accompanying tests for flake clone.
1 parent 5caebab commit 6d0f4fa

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/libfetchers/fetchers.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,9 @@ void InputScheme::clone(
495495

496496
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying '%s' to %s...", input2.to_string(), destDir));
497497

498-
auto source = sinkToSource([&](Sink & sink) { accessor->dumpPath(CanonPath::root, sink); });
499-
500-
restorePath(destDir, *source);
498+
RestoreSink sink(/*startFsync=*/false);
499+
sink.dstPath = destDir;
500+
copyRecursive(*accessor, CanonPath::root, sink, CanonPath::root);
501501
}
502502

503503
std::optional<ExperimentalFeature> InputScheme::experimentalFeature() const

src/libutil/fs-sink.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ void copyRecursive(SourceAccessor & accessor, const CanonPath & from, FileSystem
3737
sink.createDirectory(to, [&](FileSystemObjectSink & dirSink, const CanonPath & relDirPath) {
3838
for (auto & [name, _] : accessor.readDirectory(from)) {
3939
copyRecursive(accessor, from / name, dirSink, relDirPath / name);
40-
break;
4140
}
4241
});
4342
break;

0 commit comments

Comments
 (0)