lib/repo: Fix handling of missing summary files when downloading

The API for downloading a summary file can legitimately return NULL for
the summary file contents when it returns TRUE (success). This indicates
an error 404 — the summary file was not found.

Two call sites were not handling that correctly, which was causing later
assertion failures.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1061

Closes: #1065
Approved by: cgwalters
This commit is contained in:
Philip Withnall authored and Atomic Bot committed 2017-08-08 15:33:45 +00:00
1 parent 86dce4b252
commit 1672e2eee0
2 files changed
+17 -1

No files matched your search

+9 -1
View File
@@ -556,7 +556,8 @@ get_refs_and_checksums_from_summary (GBytes *summary_bytes,
}
/* Download the summary file from @remote, and return the bytes of the file in
* @out_summary_bytes. */
* @out_summary_bytes. This will return %TRUE and set @out_summary_bytes to %NULL
* if the summary file does not exist. */
static gboolean
fetch_summary_from_remote (OstreeRepo *repo,
OstreeRemote *remote,
@@ -648,6 +649,13 @@ get_checksums (OstreeRepoFinderAvahi *finder,
error))
return FALSE;
if (summary_bytes == NULL)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"No summary file found on server");
return FALSE;
}
return get_refs_and_checksums_from_summary (summary_bytes, supported_ref_to_checksum, error);
}