From ade35e330801db60bc0fbbf0b0323c7d79137729 Mon Sep 17 00:00:00 2001 From: dehann Date: Tue, 15 Aug 2023 22:05:11 -0700 Subject: [PATCH] better data handling --- src/DataBlobs/services/BlobPacking.jl | 3 +++ src/DataBlobs/services/HelpersDataWrapEntryBlob.jl | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/DataBlobs/services/BlobPacking.jl b/src/DataBlobs/services/BlobPacking.jl index e64cf4e2..82a4df74 100644 --- a/src/DataBlobs/services/BlobPacking.jl +++ b/src/DataBlobs/services/BlobPacking.jl @@ -51,6 +51,9 @@ function unpackBlob(::Type{format"JSON"}, blob::Vector{UInt8}) return String(copy(blob)) end +unpackBlob(entry::BlobEntry, blob::Vector{UInt8}) = unpackBlob(entry.mimeType, blob) +unpackBlob(eb::Pair{<:BlobEntry, Vector{UInt8}}) = unpackBlob(eb[1], eb[2]) + # 2/ FileIO function packBlob(::Type{T}, data::Any; kwargs...) where T <: DataFormat diff --git a/src/DataBlobs/services/HelpersDataWrapEntryBlob.jl b/src/DataBlobs/services/HelpersDataWrapEntryBlob.jl index 79df5175..38ea1f34 100644 --- a/src/DataBlobs/services/HelpersDataWrapEntryBlob.jl +++ b/src/DataBlobs/services/HelpersDataWrapEntryBlob.jl @@ -92,8 +92,12 @@ function getData( lbls = (s->s.label).(de_) idx = sortperm(lbls; rev=getlast) _first(s) = s - _first(s::AbstractVector) = s[1] + _first(s::AbstractVector) = 0 < length(s) ? s[1] : nothing de = _first(de_[idx]) + if isnothing(de) + @error "Could not find in $vlabel the key $key" + return nothing + end db = getBlob(dfg, de) checkhash && assertHash(de, db, hashfunction=hashfunction)