-- Copyright (c) 2024 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.

local file_sec = require('utils.file')
local vos = require('utils.vos')

local m = {}

local VERIFY_RESULT_FILE = '/data/import_bundle/result.txt'
local EMPTY_FILE_CONTENT = 'No import result was found.'

function m.get_verify_result()
    if not vos.get_file_accessible(VERIFY_RESULT_FILE) then
        return EMPTY_FILE_CONTENT
    end
    local f = file_sec.open_s(VERIFY_RESULT_FILE, 'r')
    if not f then
        return EMPTY_FILE_CONTENT
    end
    local content = f:read('a')
    f:close()
    content = content:gsub('\n$', '')
    if #content == 0 then
        return EMPTY_FILE_CONTENT
    end
    return content
end

return m