From 9551f7d402946598938ce0e8ccdc4265788cbd24 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 28 Aug 2025 13:26:06 +0200 Subject: [PATCH] image-source: Make flatpak_image_source_new public And check that the digest is a sha256 hash. Will be used in the next commits. --- common/flatpak-image-source-private.h | 6 ++++++ common/flatpak-image-source.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common/flatpak-image-source-private.h b/common/flatpak-image-source-private.h index beca07b0..42f1a5bb 100644 --- a/common/flatpak-image-source-private.h +++ b/common/flatpak-image-source-private.h @@ -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, diff --git a/common/flatpak-image-source.c b/common/flatpak-image-source.c index 3844d37e..ef29a976 100644 --- a/common/flatpak-image-source.c +++ b/common/flatpak-image-source.c @@ -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);