mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Fix build to use CanonPath in new FSO sinks
This commit is contained in:
parent
86420753ec
commit
4fd8f19ecf
6 changed files with 30 additions and 24 deletions
|
@ -909,9 +909,12 @@ struct GitFileSystemObjectSinkImpl : GitFileSystemObjectSink
|
||||||
addToTree(*pathComponents.rbegin(), oid, GIT_FILEMODE_LINK);
|
addToTree(*pathComponents.rbegin(), oid, GIT_FILEMODE_LINK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createHardlink(const Path & path, const CanonPath & target) override
|
void createHardlink(const CanonPath & path, const CanonPath & target) override
|
||||||
{
|
{
|
||||||
auto pathComponents = tokenizeString<std::vector<std::string>>(path, "/");
|
std::vector<std::string> pathComponents;
|
||||||
|
for (auto & c : path)
|
||||||
|
pathComponents.emplace_back(c);
|
||||||
|
|
||||||
if (!prepareDirs(pathComponents, false)) return;
|
if (!prepareDirs(pathComponents, false)) return;
|
||||||
|
|
||||||
// We can't just look up the path from the start of the root, since
|
// We can't just look up the path from the start of the root, since
|
||||||
|
|
|
@ -51,7 +51,7 @@ struct ExtendedFileSystemObjectSink : virtual FileSystemObjectSink
|
||||||
* Create a hard link. The target must be the path of a previously
|
* Create a hard link. The target must be the path of a previously
|
||||||
* encountered file relative to the root of the FSO.
|
* encountered file relative to the root of the FSO.
|
||||||
*/
|
*/
|
||||||
virtual void createHardlink(const Path & path, const CanonPath & target) = 0;
|
virtual void createHardlink(const CanonPath & path, const CanonPath & target) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -196,7 +196,7 @@ time_t unpackTarfileToSink(TarArchive & archive, ExtendedFileSystemObjectSink &
|
||||||
lastModified = std::max(lastModified, archive_entry_mtime(entry));
|
lastModified = std::max(lastModified, archive_entry_mtime(entry));
|
||||||
|
|
||||||
if (auto target = archive_entry_hardlink(entry)) {
|
if (auto target = archive_entry_hardlink(entry)) {
|
||||||
parseSink.createHardlink(path, CanonPath(target));
|
parseSink.createHardlink(cpath, CanonPath(target));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,17 +62,18 @@ TEST_F(GitUtilsTest, sink_basic)
|
||||||
// general, and I can't imagine that "non-conventional" archives or any other source to be handled by
|
// general, and I can't imagine that "non-conventional" archives or any other source to be handled by
|
||||||
// this sink.
|
// this sink.
|
||||||
|
|
||||||
sink->createDirectory("foo-1.1");
|
sink->createDirectory(CanonPath("foo-1.1"));
|
||||||
|
|
||||||
sink->createRegularFile(
|
sink->createRegularFile(CanonPath("foo-1.1/hello"), [](CreateRegularFileSink & fileSink) {
|
||||||
"foo-1.1/hello", [](CreateRegularFileSink & fileSink) { writeString(fileSink, "hello world", false); });
|
writeString(fileSink, "hello world", false);
|
||||||
sink->createRegularFile("foo-1.1/bye", [](CreateRegularFileSink & fileSink) {
|
});
|
||||||
|
sink->createRegularFile(CanonPath("foo-1.1/bye"), [](CreateRegularFileSink & fileSink) {
|
||||||
writeString(fileSink, "thanks for all the fish", false);
|
writeString(fileSink, "thanks for all the fish", false);
|
||||||
});
|
});
|
||||||
sink->createSymlink("foo-1.1/bye-link", "bye");
|
sink->createSymlink(CanonPath("foo-1.1/bye-link"), "bye");
|
||||||
sink->createDirectory("foo-1.1/empty");
|
sink->createDirectory(CanonPath("foo-1.1/empty"));
|
||||||
sink->createDirectory("foo-1.1/links");
|
sink->createDirectory(CanonPath("foo-1.1/links"));
|
||||||
sink->createHardlink("foo-1.1/links/foo", CanonPath("foo-1.1/hello"));
|
sink->createHardlink(CanonPath("foo-1.1/links/foo"), CanonPath("foo-1.1/hello"));
|
||||||
|
|
||||||
// sink->createHardlink("foo-1.1/links/foo-2", CanonPath("foo-1.1/hello"));
|
// sink->createHardlink("foo-1.1/links/foo-2", CanonPath("foo-1.1/hello"));
|
||||||
|
|
||||||
|
@ -92,13 +93,14 @@ TEST_F(GitUtilsTest, sink_hardlink)
|
||||||
auto repo = openRepo();
|
auto repo = openRepo();
|
||||||
auto sink = repo->getFileSystemObjectSink();
|
auto sink = repo->getFileSystemObjectSink();
|
||||||
|
|
||||||
sink->createDirectory("foo-1.1");
|
sink->createDirectory(CanonPath("foo-1.1"));
|
||||||
|
|
||||||
sink->createRegularFile(
|
sink->createRegularFile(CanonPath("foo-1.1/hello"), [](CreateRegularFileSink & fileSink) {
|
||||||
"foo-1.1/hello", [](CreateRegularFileSink & fileSink) { writeString(fileSink, "hello world", false); });
|
writeString(fileSink, "hello world", false);
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sink->createHardlink("foo-1.1/link", CanonPath("hello"));
|
sink->createHardlink(CanonPath("foo-1.1/link"), CanonPath("hello"));
|
||||||
FAIL() << "Expected an exception";
|
FAIL() << "Expected an exception";
|
||||||
} catch (const nix::Error & e) {
|
} catch (const nix::Error & e) {
|
||||||
ASSERT_THAT(e.msg(), testing::HasSubstr("invalid hard link target"));
|
ASSERT_THAT(e.msg(), testing::HasSubstr("invalid hard link target"));
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
|
|
||||||
namespace nix::test {
|
namespace nix::test {
|
||||||
|
|
||||||
void TracingFileSystemObjectSink::createDirectory(const Path & path)
|
void TracingFileSystemObjectSink::createDirectory(const CanonPath & path)
|
||||||
{
|
{
|
||||||
std::cerr << "createDirectory(" << path << ")\n";
|
std::cerr << "createDirectory(" << path << ")\n";
|
||||||
sink.createDirectory(path);
|
sink.createDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TracingFileSystemObjectSink::createRegularFile(const Path & path, std::function<void(CreateRegularFileSink &)> fn)
|
void TracingFileSystemObjectSink::createRegularFile(
|
||||||
|
const CanonPath & path, std::function<void(CreateRegularFileSink &)> fn)
|
||||||
{
|
{
|
||||||
std::cerr << "createRegularFile(" << path << ")\n";
|
std::cerr << "createRegularFile(" << path << ")\n";
|
||||||
sink.createRegularFile(path, [&](CreateRegularFileSink & crf) {
|
sink.createRegularFile(path, [&](CreateRegularFileSink & crf) {
|
||||||
|
@ -18,13 +19,13 @@ void TracingFileSystemObjectSink::createRegularFile(const Path & path, std::func
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TracingFileSystemObjectSink::createSymlink(const Path & path, const std::string & target)
|
void TracingFileSystemObjectSink::createSymlink(const CanonPath & path, const std::string & target)
|
||||||
{
|
{
|
||||||
std::cerr << "createSymlink(" << path << ", target: " << target << ")\n";
|
std::cerr << "createSymlink(" << path << ", target: " << target << ")\n";
|
||||||
sink.createSymlink(path, target);
|
sink.createSymlink(path, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TracingExtendedFileSystemObjectSink::createHardlink(const Path & path, const CanonPath & target)
|
void TracingExtendedFileSystemObjectSink::createHardlink(const CanonPath & path, const CanonPath & target)
|
||||||
{
|
{
|
||||||
std::cerr << "createHardlink(" << path << ", target: " << target << ")\n";
|
std::cerr << "createHardlink(" << path << ", target: " << target << ")\n";
|
||||||
sink.createHardlink(path, target);
|
sink.createHardlink(path, target);
|
||||||
|
|
|
@ -15,11 +15,11 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void createDirectory(const Path & path) override;
|
void createDirectory(const CanonPath & path) override;
|
||||||
|
|
||||||
void createRegularFile(const Path & path, std::function<void(CreateRegularFileSink &)> fn);
|
void createRegularFile(const CanonPath & path, std::function<void(CreateRegularFileSink &)> fn) override;
|
||||||
|
|
||||||
void createSymlink(const Path & path, const std::string & target);
|
void createSymlink(const CanonPath & path, const std::string & target) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void createHardlink(const Path & path, const CanonPath & target);
|
void createHardlink(const CanonPath & path, const CanonPath & target) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue