mirror of
https://github.com/NixOS/nix.git
synced 2024-11-29 18:22:27 +00:00
Style fixes
This commit is contained in:
parent
92ac8df0ec
commit
35a0ac1838
@ -4,11 +4,13 @@
|
|||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
std::string FixedOutputHash::printMethodAlgo() const {
|
std::string FixedOutputHash::printMethodAlgo() const
|
||||||
|
{
|
||||||
return makeFileIngestionPrefix(method) + printHashType(hash.type);
|
return makeFileIngestionPrefix(method) + printHashType(hash.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string makeFileIngestionPrefix(const FileIngestionMethod m) {
|
std::string makeFileIngestionPrefix(const FileIngestionMethod m)
|
||||||
|
{
|
||||||
switch (m) {
|
switch (m) {
|
||||||
case FileIngestionMethod::Flat:
|
case FileIngestionMethod::Flat:
|
||||||
return "";
|
return "";
|
||||||
@ -26,7 +28,8 @@ std::string makeFixedOutputCA(FileIngestionMethod method, const Hash & hash)
|
|||||||
+ hash.to_string(Base32, true);
|
+ hash.to_string(Base32, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string renderContentAddress(ContentAddress ca) {
|
std::string renderContentAddress(ContentAddress ca)
|
||||||
|
{
|
||||||
return std::visit(overloaded {
|
return std::visit(overloaded {
|
||||||
[](TextHash th) {
|
[](TextHash th) {
|
||||||
return "text:" + th.hash.to_string(Base32, true);
|
return "text:" + th.hash.to_string(Base32, true);
|
||||||
@ -37,7 +40,8 @@ std::string renderContentAddress(ContentAddress ca) {
|
|||||||
}, ca);
|
}, ca);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string renderContentAddressMethod(ContentAddressMethod cam) {
|
std::string renderContentAddressMethod(ContentAddressMethod cam)
|
||||||
|
{
|
||||||
return std::visit(overloaded {
|
return std::visit(overloaded {
|
||||||
[](TextHashMethod &th) {
|
[](TextHashMethod &th) {
|
||||||
return std::string{"text:"} + printHashType(htSHA256);
|
return std::string{"text:"} + printHashType(htSHA256);
|
||||||
@ -51,7 +55,8 @@ std::string renderContentAddressMethod(ContentAddressMethod cam) {
|
|||||||
/*
|
/*
|
||||||
Parses content address strings up to the hash.
|
Parses content address strings up to the hash.
|
||||||
*/
|
*/
|
||||||
static ContentAddressMethod parseContentAddressMethodPrefix(std::string_view & rest) {
|
static ContentAddressMethod parseContentAddressMethodPrefix(std::string_view & rest)
|
||||||
|
{
|
||||||
std::string_view wholeInput { rest };
|
std::string_view wholeInput { rest };
|
||||||
|
|
||||||
std::string_view prefix;
|
std::string_view prefix;
|
||||||
@ -113,16 +118,19 @@ ContentAddress parseContentAddress(std::string_view rawCa) {
|
|||||||
}, caMethod);
|
}, caMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentAddressMethod parseContentAddressMethod(std::string_view caMethod) {
|
ContentAddressMethod parseContentAddressMethod(std::string_view caMethod)
|
||||||
|
{
|
||||||
std::string_view asPrefix {std::string{caMethod} + ":"};
|
std::string_view asPrefix {std::string{caMethod} + ":"};
|
||||||
return parseContentAddressMethodPrefix(asPrefix);
|
return parseContentAddressMethodPrefix(asPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ContentAddress> parseContentAddressOpt(std::string_view rawCaOpt) {
|
std::optional<ContentAddress> parseContentAddressOpt(std::string_view rawCaOpt)
|
||||||
return rawCaOpt == "" ? std::optional<ContentAddress> {} : parseContentAddress(rawCaOpt);
|
{
|
||||||
|
return rawCaOpt == "" ? std::optional<ContentAddress>() : parseContentAddress(rawCaOpt);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string renderContentAddress(std::optional<ContentAddress> ca) {
|
std::string renderContentAddress(std::optional<ContentAddress> ca)
|
||||||
|
{
|
||||||
return ca ? renderContentAddress(*ca) : "";
|
return ca ? renderContentAddress(*ca) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,12 @@ struct ClientSettings
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void writeValidPathInfo(ref<Store> store, unsigned int clientVersion, Sink & to, std::shared_ptr<const ValidPathInfo> info) {
|
static void writeValidPathInfo(
|
||||||
|
ref<Store> store,
|
||||||
|
unsigned int clientVersion,
|
||||||
|
Sink & to,
|
||||||
|
std::shared_ptr<const ValidPathInfo> info)
|
||||||
|
{
|
||||||
to << (info->deriver ? store->printStorePath(*info->deriver) : "")
|
to << (info->deriver ? store->printStorePath(*info->deriver) : "")
|
||||||
<< info->narHash.to_string(Base16, false);
|
<< info->narHash.to_string(Base16, false);
|
||||||
writeStorePaths(*store, to, info->references);
|
writeStorePaths(*store, to, info->references);
|
||||||
|
@ -422,7 +422,8 @@ void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ref<const ValidPathInfo> RemoteStore::readValidPathInfo(ConnectionHandle & conn, const StorePath & path) {
|
ref<const ValidPathInfo> RemoteStore::readValidPathInfo(ConnectionHandle & conn, const StorePath & path)
|
||||||
|
{
|
||||||
auto deriver = readString(conn->from);
|
auto deriver = readString(conn->from);
|
||||||
auto narHash = Hash::parseAny(readString(conn->from), htSHA256);
|
auto narHash = Hash::parseAny(readString(conn->from), htSHA256);
|
||||||
auto info = make_ref<ValidPathInfo>(path, narHash);
|
auto info = make_ref<ValidPathInfo>(path, narHash);
|
||||||
@ -533,7 +534,12 @@ std::optional<StorePath> RemoteStore::queryPathFromHashPart(const std::string &
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ref<const ValidPathInfo> RemoteStore::addCAToStore(Source & dump, const string & name, ContentAddressMethod caMethod, StorePathSet references, RepairFlag repair)
|
ref<const ValidPathInfo> RemoteStore::addCAToStore(
|
||||||
|
Source & dump,
|
||||||
|
const string & name,
|
||||||
|
ContentAddressMethod caMethod,
|
||||||
|
const StorePathSet & references,
|
||||||
|
RepairFlag repair)
|
||||||
{
|
{
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
|
|
||||||
@ -603,6 +609,7 @@ ref<const ValidPathInfo> RemoteStore::addCAToStore(Source & dump, const string &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StorePath RemoteStore::addToStoreFromDump(Source & dump, const string & name,
|
StorePath RemoteStore::addToStoreFromDump(Source & dump, const string & name,
|
||||||
FileIngestionMethod method, HashType hashType, RepairFlag repair)
|
FileIngestionMethod method, HashType hashType, RepairFlag repair)
|
||||||
{
|
{
|
||||||
@ -964,8 +971,8 @@ std::exception_ptr RemoteStore::Connection::processStderr(Sink * sink, Source *
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ConnectionHandle::withFramedSink(std::function<void(Sink &sink)> fun)
|
||||||
ConnectionHandle::withFramedSink(std::function<void(Sink &sink)> fun) {
|
{
|
||||||
(*this)->to.flush();
|
(*this)->to.flush();
|
||||||
|
|
||||||
std::exception_ptr ex;
|
std::exception_ptr ex;
|
||||||
|
@ -64,7 +64,12 @@ public:
|
|||||||
SubstitutablePathInfos & infos) override;
|
SubstitutablePathInfos & infos) override;
|
||||||
|
|
||||||
/* Add a content-addressable store path. `dump` will be drained. */
|
/* Add a content-addressable store path. `dump` will be drained. */
|
||||||
ref<const ValidPathInfo> addCAToStore(Source & dump, const string & name, ContentAddressMethod caMethod, StorePathSet references, RepairFlag repair);
|
ref<const ValidPathInfo> addCAToStore(
|
||||||
|
Source & dump,
|
||||||
|
const string & name,
|
||||||
|
ContentAddressMethod caMethod,
|
||||||
|
const StorePathSet & references,
|
||||||
|
RepairFlag repair);
|
||||||
|
|
||||||
/* Add a content-addressable store path. Does not support references. `dump` will be drained. */
|
/* Add a content-addressable store path. Does not support references. `dump` will be drained. */
|
||||||
StorePath addToStoreFromDump(Source & dump, const string & name,
|
StorePath addToStoreFromDump(Source & dump, const string & name,
|
||||||
|
Loading…
Reference in New Issue
Block a user