From 2f3975f39b0df06ab0bf25c889f439d2bc217de6 Mon Sep 17 00:00:00 2001 From: Santy-Wang Date: Tue, 2 Mar 2021 19:16:48 +0800 Subject: [PATCH] hack: check cached file (#8317) --- platforms/minigame/common/engine/AssetManager.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/platforms/minigame/common/engine/AssetManager.js b/platforms/minigame/common/engine/AssetManager.js index 922dc68fee..b02753659f 100644 --- a/platforms/minigame/common/engine/AssetManager.js +++ b/platforms/minigame/common/engine/AssetManager.js @@ -1,5 +1,5 @@ const cacheManager = require('../cache-manager'); -const { fs, downloadFile, readText, readArrayBuffer, readJson, loadSubpackage, getUserDataPath } = window.fsUtils; +const { fs, downloadFile, readText, readArrayBuffer, readJson, loadSubpackage, getUserDataPath, exists } = window.fsUtils; const REGEX = /^https?:\/\/.*/; @@ -135,7 +135,15 @@ function loadFont (url, options, onComplete) { onComplete(null, fontFamily || 'Arial'); } -function doNothing (content, options, onComplete) { onComplete(null, content); } +function doNothing (content, options, onComplete) { + exists(content, (existence) => { + if (existence) { + onComplete(null, content); + } else { + onComplete(new Error(`file ${content} does not exist!`)); + } + }); +} function downloadAsset (url, options, onComplete) { download(url, doNothing, options, options.onFileProgress, onComplete);