From 7c9e7ee412751331cb9e6cae74bd0f6d7b2767bd Mon Sep 17 00:00:00 2001 From: nonameShijian <2954700422@qq.com> Date: Sun, 14 Apr 2024 01:38:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84checkFileList=E5=86=99?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/game/index.js | 54 +++++++++++++------------------------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/noname/game/index.js b/noname/game/index.js index 54f42cc93..c606e1b76 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -890,51 +890,29 @@ export class Game { * @param { Function } proceed */ checkFileList(updates, proceed) { + if (!Array.isArray(updates) || !updates.length) proceed(); let n = updates.length; - if (!n) { - proceed(n); - } for (let i = 0; i < updates.length; i++) { if (lib.node && lib.node.fs) { - lib.node.fs.access(__dirname + '/' + updates[i], (function (entry) { - return function (err) { - if (!err) { - let stat = lib.node.fs.statSync(__dirname + '/' + entry); - if (stat.size == 0) { - // @ts-ignore - err = true; - } - } - if (err) { - n--; - if (n == 0) { - proceed(); - } - } - else { - n--; - updates.remove(entry); - if (n == 0) { - proceed(); - } - } + lib.node.fs.access(__dirname + '/' + updates[i], err => { + if (!err) { + let stat = lib.node.fs.statSync(__dirname + '/' + updates[i]); + // @ts-ignore + if (stat.size == 0) err = true; } - }(updates[i]))); + n--; + if (!err) updates.remove(updates[i]); + if (n == 0) proceed(); + }); } else { - window.resolveLocalFileSystemURL(nonameInitialized + updates[i], (function (name) { - return function (entry) { - n--; - updates.remove(name); - if (n == 0) { - proceed(); - } - } - }(updates[i])), function () { + window.resolveLocalFileSystemURL(nonameInitialized + updates[i], () => { n--; - if (n == 0) { - proceed(); - } + updates.remove(updates[i]); + if (n == 0) proceed(); + }, () => { + n--; + if (n == 0) proceed(); }); } }