[adapters] 修复未同步 cacheFiles 的问题,并降低通信消耗

This commit is contained in:
SmallMain 2024-10-22 17:14:49 +08:00
parent cf7307d7f5
commit 290b29770c
No known key found for this signature in database
2 changed files with 4 additions and 7 deletions

View File

@ -16,11 +16,8 @@ var assetManagerWorkerAdapter = {
},
// 添加缓存文件记录
addCachedFiles(args, cmdId, callback) {
const addedFiles = args[0];
for (let i = 0, l = addedFiles.length; i < l; i++) {
const [id, cacheBundleRoot, localPath, time] = addedFiles[i];
const [id, cacheBundleRoot, localPath, time] = args[0];
cc.assetManager.cacheManager.cachedFiles.add(id, { bundle: cacheBundleRoot, url: localPath, lastTime: time });
}
},
};

View File

@ -189,7 +189,7 @@ var cacheManager_worker = {
self.cachedFiles[id] = { bundle: cacheBundleRoot, url: localPath, lastTime: time };
delete self.cacheQueue[id];
self.writeCacheFile();
// TODO main.assetManager.addCachedFiles([[id, cacheBundleRoot, localPath, time]]);
main.assetManager.addCachedFiles([id, cacheBundleRoot, localPath, time]);
if (_callback) _callback(id, cacheBundleRoot, localPath, time);
}
if (!isEmptyObject(self.cacheQueue)) {
@ -334,7 +334,7 @@ var cacheManager_worker = {
}
self.cachedFiles[id] = { bundle: cacheBundleRoot, url: targetPath, lastTime: time };
self.writeCacheFile();
main.assetManager.addCachedFiles([[id, cacheBundleRoot, targetPath, time]]);
main.assetManager.addCachedFiles([id, cacheBundleRoot, targetPath, time]);
onComplete && onComplete(null, targetPath);
});
},