diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-01-08 12:22:21 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-01-08 12:22:21 +0100 |
commit | 6548b89cc4eb214cb4632fd4332c610f2d1f0a9d (patch) | |
tree | 1d9044a0f0602993c5a538ce2231d8d569aeb2a5 /src/libstore/nar-info.cc | |
parent | 29a445840a4f01dfb1533806f8dfc28f7dc4bee9 (diff) |
string2Int(): Return std::optional
Diffstat (limited to 'src/libstore/nar-info.cc')
-rw-r--r-- | src/libstore/nar-info.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstore/nar-info.cc b/src/libstore/nar-info.cc index 3454f34bb..49079388a 100644 --- a/src/libstore/nar-info.cc +++ b/src/libstore/nar-info.cc @@ -46,14 +46,18 @@ NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & else if (name == "FileHash") fileHash = parseHashField(value); else if (name == "FileSize") { - if (!string2Int(value, fileSize)) throw corrupt(); + auto n = string2Int<decltype(fileSize)>(value); + if (!n) throw corrupt(); + fileSize = *n; } else if (name == "NarHash") { narHash = parseHashField(value); haveNarHash = true; } else if (name == "NarSize") { - if (!string2Int(value, narSize)) throw corrupt(); + auto n = string2Int<decltype(narSize)>(value); + if (!n) throw corrupt(); + narSize = *n; } else if (name == "References") { auto refs = tokenizeString<Strings>(value, " "); |