aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers
diff options
context:
space:
mode:
authorMatthew Kenigsberg <matthewkenigsberg@gmail.com>2020-10-28 09:41:18 -0500
committerMatthew Kenigsberg <matthewkenigsberg@gmail.com>2020-10-28 17:54:28 -0500
commit6a4bf535d8126d8dc7306b3940bb49e0cc014a56 (patch)
tree7d64f9d438bbdfdde69ad81f7ed8af4c18fca3fb /src/libfetchers
parent5ac911bad6e5760759bcb62772cac1ddc056b773 (diff)
Capitalize JSON for consistency
Diffstat (limited to 'src/libfetchers')
-rw-r--r--src/libfetchers/attrs.cc4
-rw-r--r--src/libfetchers/attrs.hh2
-rw-r--r--src/libfetchers/cache.cc20
-rw-r--r--src/libfetchers/fetchers.cc6
-rw-r--r--src/libfetchers/registry.cc6
5 files changed, 19 insertions, 19 deletions
diff --git a/src/libfetchers/attrs.cc b/src/libfetchers/attrs.cc
index 1e59faa73..720b19fcd 100644
--- a/src/libfetchers/attrs.cc
+++ b/src/libfetchers/attrs.cc
@@ -23,7 +23,7 @@ Attrs jsonToAttrs(const nlohmann::json & json)
return attrs;
}
-nlohmann::json attrsToJson(const Attrs & attrs)
+nlohmann::json attrsToJSON(const Attrs & attrs)
{
nlohmann::json json;
for (auto & attr : attrs) {
@@ -44,7 +44,7 @@ std::optional<std::string> maybeGetStrAttr(const Attrs & attrs, const std::strin
if (i == attrs.end()) return {};
if (auto v = std::get_if<std::string>(&i->second))
return *v;
- throw Error("input attribute '%s' is not a string %s", name, attrsToJson(attrs).dump());
+ throw Error("input attribute '%s' is not a string %s", name, attrsToJSON(attrs).dump());
}
std::string getStrAttr(const Attrs & attrs, const std::string & name)
diff --git a/src/libfetchers/attrs.hh b/src/libfetchers/attrs.hh
index 56bcdcfc8..a2d53a7bf 100644
--- a/src/libfetchers/attrs.hh
+++ b/src/libfetchers/attrs.hh
@@ -13,7 +13,7 @@ typedef std::map<std::string, Attr> Attrs;
Attrs jsonToAttrs(const nlohmann::json & json);
-nlohmann::json attrsToJson(const Attrs & attrs);
+nlohmann::json attrsToJSON(const Attrs & attrs);
std::optional<std::string> maybeGetStrAttr(const Attrs & attrs, const std::string & name);
diff --git a/src/libfetchers/cache.cc b/src/libfetchers/cache.cc
index e1c7f3dee..34ff6f85b 100644
--- a/src/libfetchers/cache.cc
+++ b/src/libfetchers/cache.cc
@@ -55,8 +55,8 @@ struct CacheImpl : Cache
bool immutable) override
{
_state.lock()->add.use()
- (attrsToJson(inAttrs).dump())
- (attrsToJson(infoAttrs).dump())
+ (attrsToJSON(inAttrs).dump())
+ (attrsToJSON(infoAttrs).dump())
(store->printStorePath(storePath))
(immutable)
(time(0)).exec();
@@ -70,7 +70,7 @@ struct CacheImpl : Cache
if (!res->expired)
return std::make_pair(std::move(res->infoAttrs), std::move(res->storePath));
debug("ignoring expired cache entry '%s'",
- attrsToJson(inAttrs).dump());
+ attrsToJSON(inAttrs).dump());
}
return {};
}
@@ -81,15 +81,15 @@ struct CacheImpl : Cache
{
auto state(_state.lock());
- auto inAttrsJson = attrsToJson(inAttrs).dump();
+ auto inAttrsJSON = attrsToJSON(inAttrs).dump();
- auto stmt(state->lookup.use()(inAttrsJson));
+ auto stmt(state->lookup.use()(inAttrsJSON));
if (!stmt.next()) {
- debug("did not find cache entry for '%s'", inAttrsJson);
+ debug("did not find cache entry for '%s'", inAttrsJSON);
return {};
}
- auto infoJson = stmt.getStr(0);
+ auto infoJSON = stmt.getStr(0);
auto storePath = store->parseStorePath(stmt.getStr(1));
auto immutable = stmt.getInt(2) != 0;
auto timestamp = stmt.getInt(3);
@@ -97,16 +97,16 @@ struct CacheImpl : Cache
store->addTempRoot(storePath);
if (!store->isValidPath(storePath)) {
// FIXME: we could try to substitute 'storePath'.
- debug("ignoring disappeared cache entry '%s'", inAttrsJson);
+ debug("ignoring disappeared cache entry '%s'", inAttrsJSON);
return {};
}
debug("using cache entry '%s' -> '%s', '%s'",
- inAttrsJson, infoJson, store->printStorePath(storePath));
+ inAttrsJSON, infoJSON, store->printStorePath(storePath));
return Result {
.expired = !immutable && (settings.tarballTtl.get() == 0 || timestamp + settings.tarballTtl < time(0)),
- .infoAttrs = jsonToAttrs(nlohmann::json::parse(infoJson)),
+ .infoAttrs = jsonToAttrs(nlohmann::json::parse(infoJSON)),
.storePath = std::move(storePath)
};
}
diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc
index 49851f7bc..e6741a451 100644
--- a/src/libfetchers/fetchers.cc
+++ b/src/libfetchers/fetchers.cc
@@ -65,7 +65,7 @@ Input Input::fromAttrs(Attrs && attrs)
ParsedURL Input::toURL() const
{
if (!scheme)
- throw Error("cannot show unsupported input '%s'", attrsToJson(attrs));
+ throw Error("cannot show unsupported input '%s'", attrsToJSON(attrs));
return scheme->toURL(*this);
}
@@ -110,7 +110,7 @@ bool Input::contains(const Input & other) const
std::pair<Tree, Input> Input::fetch(ref<Store> store) const
{
if (!scheme)
- throw Error("cannot fetch unsupported input '%s'", attrsToJson(toAttrs()));
+ throw Error("cannot fetch unsupported input '%s'", attrsToJSON(toAttrs()));
/* The tree may already be in the Nix store, or it could be
substituted (which is often faster than fetching from the
@@ -247,7 +247,7 @@ std::optional<time_t> Input::getLastModified() const
ParsedURL InputScheme::toURL(const Input & input)
{
- throw Error("don't know how to convert input '%s' to a URL", attrsToJson(input.attrs));
+ throw Error("don't know how to convert input '%s' to a URL", attrsToJSON(input.attrs));
}
Input InputScheme::applyOverrides(
diff --git a/src/libfetchers/registry.cc b/src/libfetchers/registry.cc
index 2426882ca..81b2227de 100644
--- a/src/libfetchers/registry.cc
+++ b/src/libfetchers/registry.cc
@@ -60,10 +60,10 @@ void Registry::write(const Path & path)
nlohmann::json arr;
for (auto & entry : entries) {
nlohmann::json obj;
- obj["from"] = attrsToJson(entry.from.toAttrs());
- obj["to"] = attrsToJson(entry.to.toAttrs());
+ obj["from"] = attrsToJSON(entry.from.toAttrs());
+ obj["to"] = attrsToJSON(entry.to.toAttrs());
if (!entry.extraAttrs.empty())
- obj["to"].update(attrsToJson(entry.extraAttrs));
+ obj["to"].update(attrsToJSON(entry.extraAttrs));
if (entry.exact)
obj["exact"] = true;
arr.emplace_back(std::move(obj));