image-source: Make flatpak_image_source_new public

And check that the digest is a sha256 hash.

Will be used in the next commits.
This commit is contained in:
Sebastian Wick
2025-08-28 13:26:06 +02:00
parent 86b000c34b
commit 9551f7d402
2 changed files with 13 additions and 1 deletions

View File

@@ -32,6 +32,12 @@ G_DECLARE_FINAL_TYPE (FlatpakImageSource,
FLATPAK, IMAGE_SOURCE,
GObject)
FlatpakImageSource *flatpak_image_source_new (FlatpakOciRegistry *registry,
const char *repository,
const char *digest,
GCancellable *cancellable,
GError **error);
FlatpakImageSource *flatpak_image_source_new_local (GFile *file,
const char *reference,
GCancellable *cancellable,

View File

@@ -68,7 +68,7 @@ flatpak_image_source_init (FlatpakImageSource *self)
{
}
static FlatpakImageSource *
FlatpakImageSource *
flatpak_image_source_new (FlatpakOciRegistry *registry,
const char *repository,
const char *digest,
@@ -78,6 +78,12 @@ flatpak_image_source_new (FlatpakOciRegistry *registry,
g_autoptr(FlatpakImageSource) self = NULL;
g_autoptr(FlatpakOciVersioned) versioned = NULL;
if (!g_str_has_prefix (digest, "sha256:"))
{
flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Only sha256 image checksums are supported"));
return NULL;
}
self = g_object_new (FLATPAK_TYPE_IMAGE_SOURCE, NULL);
self->registry = g_object_ref (registry);
self->repository = g_strdup (repository);