mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-12-02 02:16:15 +02:00
Use Bindings::{get,need} instead of find
This commit is contained in:
parent
a73be28717
commit
eadb45c4db
1 changed files with 10 additions and 12 deletions
|
@ -199,26 +199,24 @@ static int main_nix_prefetch_url(int argc, char * * argv)
|
||||||
state->forceAttrs(v);
|
state->forceAttrs(v);
|
||||||
|
|
||||||
/* Extract the URL. */
|
/* Extract the URL. */
|
||||||
auto attr = v.attrs->find(state->symbols.create("urls"));
|
auto & attr = v.attrs->need(state->symbols.create("urls"));
|
||||||
if (attr == v.attrs->end())
|
state->forceList(*attr.value);
|
||||||
throw Error("attribute set does not contain a 'urls' attribute");
|
if (attr.value->listSize() < 1)
|
||||||
state->forceList(*attr->value);
|
|
||||||
if (attr->value->listSize() < 1)
|
|
||||||
throw Error("'urls' list is empty");
|
throw Error("'urls' list is empty");
|
||||||
url = state->forceString(*attr->value->listElems()[0]);
|
url = state->forceString(*attr.value->listElems()[0]);
|
||||||
|
|
||||||
/* Extract the hash mode. */
|
/* Extract the hash mode. */
|
||||||
attr = v.attrs->find(state->symbols.create("outputHashMode"));
|
auto attr2 = v.attrs->get(state->symbols.create("outputHashMode"));
|
||||||
if (attr == v.attrs->end())
|
if (!attr2)
|
||||||
printInfo("warning: this does not look like a fetchurl call");
|
printInfo("warning: this does not look like a fetchurl call");
|
||||||
else
|
else
|
||||||
unpack = state->forceString(*attr->value) == "recursive";
|
unpack = state->forceString(*attr2->value) == "recursive";
|
||||||
|
|
||||||
/* Extract the name. */
|
/* Extract the name. */
|
||||||
if (!name) {
|
if (!name) {
|
||||||
attr = v.attrs->find(state->symbols.create("name"));
|
auto attr3 = v.attrs->get(state->symbols.create("name"));
|
||||||
if (attr != v.attrs->end())
|
if (!attr3)
|
||||||
name = state->forceString(*attr->value);
|
name = state->forceString(*attr3->value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue