#!/bin/bash

manifestReadFromSnapshot()
{
    local repo_name="$1"
    local snapshot_id="$2"
    local app_name="$3"

    local manifest_path="$containers_dir$app_name/.libreportal-manifest.json"
    engineDumpFile "$repo_name" "$snapshot_id" "$manifest_path" 2>/dev/null
}

manifestReadField()
{
    local manifest_json="$1"
    local field="$2"

    if command -v jq >/dev/null 2>&1; then
        echo "$manifest_json" | jq -r ".${field} // empty" 2>/dev/null
    else
        echo "$manifest_json" | grep -o "\"${field}\":[[:space:]]*\"[^\"]*\"" | head -1 | sed "s/.*\"${field}\":[[:space:]]*\"\\(.*\\)\"/\\1/"
    fi
}
