alternate fix using the rest() function

This commit is contained in:
Andrew Kelley
2018-09-13 11:24:57 -04:00
parent 6d0a122816
commit e3f0ba4984
3 changed files with 15 additions and 14 deletions

View File

@@ -337,22 +337,12 @@ Error cache_hit(CacheHash *ch, Buf *out_digest) {
return ErrorInvalidFormat;
}
// We should be at the last item,
// so switch from iterating on spaces ' ' to newlines '\n'
// First, check to make sure we have the runway to do so:
if (it.index == it.buffer.len) {
Slice<uint8_t> file_path = SplitIterator_rest(&it);
if (file_path.len == 0) {
os_file_close(ch->manifest_file);
return ErrorInvalidFormat;
}
it.index++;
// Too close for missiles, Im switching to guns
it.split_bytes = str("\n");
Optional<Slice<uint8_t>> opt_file_path = SplitIterator_next(&it);
if (!opt_file_path.is_some) {
os_file_close(ch->manifest_file);
return ErrorInvalidFormat;
}
Buf *this_path = buf_create_from_slice(opt_file_path.value);
Buf *this_path = buf_create_from_slice(file_path);
if (chf->path != nullptr && !buf_eql_buf(this_path, chf->path)) {
os_file_close(ch->manifest_file);
return ErrorInvalidFormat;