context: Expose errors from builder_context_set_checksum_for()

The function only does I/O, so could fail. Expose failure to the caller
rather than hiding it.

Coverity CID: #208385

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

Closes: #74
Approved by: alexlarsson
tingping/wmclass
Philip Withnall 2017-12-05 12:16:37 +00:00 committed by Atomic Bot
parent 4e4a7c9af5
commit 26e648ae99
3 changed files with 17 additions and 11 deletions

View File

@ -425,18 +425,19 @@ builder_context_get_checksum_for (BuilderContext *self,
return g_steal_pointer (&checksum);
}
void
builder_context_set_checksum_for (BuilderContext *self,
const char *name,
const char *checksum)
gboolean
builder_context_set_checksum_for (BuilderContext *self,
const char *name,
const char *checksum,
GError **error)
{
g_autoptr(GFile) checksum_file = g_file_get_child (self->checksums_dir, name);
if (!flatpak_mkdir_p (self->checksums_dir,
NULL, NULL))
return;
NULL, error))
return FALSE;
g_file_set_contents (flatpak_file_get_path_cached (checksum_file), checksum, -1, NULL);
return g_file_set_contents (flatpak_file_get_path_cached (checksum_file), checksum, -1, error);
}
GFile *

View File

@ -109,9 +109,10 @@ void builder_context_set_rebuild_on_sdk_change (BuilderContext *self,
gboolean rebuild_on_sdk_change);
char * builder_context_get_checksum_for (BuilderContext *self,
const char *name);
void builder_context_set_checksum_for (BuilderContext *self,
const char *name,
const char *checksum);
gboolean builder_context_set_checksum_for (BuilderContext *self,
const char *name,
const char *checksum,
GError **error);
BuilderContext *builder_context_new (GFile *run_dir,
GFile *app_dir,

View File

@ -627,7 +627,11 @@ main (int argc,
}
}
builder_context_set_checksum_for (build_context, manifest_basename, json_sha256);
if (!builder_context_set_checksum_for (build_context, manifest_basename, json_sha256, &error))
{
g_printerr ("Failed to set checksum for %s: %s\n", manifest_basename, error->message);
return 1;
}
if (!builder_manifest_start (manifest, opt_allow_missing_runtimes, build_context, &error))
{