mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2025-06-12 13:01:08 -04:00
fix scripts/fetchMediaLibraryAssets.js missing some sprite assets
Assets which are referenced by a sprite but not referenced by the sound, costume, or backdrop libraries were being missed by previous versions. I also removed the default parameter to several methods in order to reduce the likelihood of similar mistakes in the future.
This commit is contained in:
parent
7b13482bc6
commit
91e16c2ab5
2 changed files with 9 additions and 9 deletions
scripts
|
@ -16,7 +16,7 @@ const describe = function (object) {
|
|||
return util.inspect(object, false, Infinity, true);
|
||||
};
|
||||
|
||||
const collectSimple = function (library, debugLabel = 'Item', dest = new Set()) {
|
||||
const collectSimple = function (library, dest, debugLabel = 'Item') {
|
||||
library.forEach(item => {
|
||||
let md5Count = 0;
|
||||
if (item.md5) {
|
||||
|
@ -37,10 +37,10 @@ const collectSimple = function (library, debugLabel = 'Item', dest = new Set())
|
|||
return dest;
|
||||
};
|
||||
|
||||
const collectAssets = function (dest = new Set()) {
|
||||
collectSimple(libraries.backdrops, 'Backdrop', dest);
|
||||
collectSimple(libraries.costumes, 'Costume', dest);
|
||||
collectSimple(libraries.sounds, 'Sound', dest);
|
||||
const collectAssets = function (dest) {
|
||||
collectSimple(libraries.backdrops, dest, 'Backdrop');
|
||||
collectSimple(libraries.costumes, dest, 'Costume');
|
||||
collectSimple(libraries.sounds, dest, 'Sound');
|
||||
libraries.sprites.forEach(sprite => {
|
||||
if (sprite.md5) {
|
||||
dest.add(sprite.md5);
|
||||
|
@ -48,10 +48,10 @@ const collectAssets = function (dest = new Set()) {
|
|||
console.warn(`Sprite has no MD5 property:\n${describe(sprite)}`);
|
||||
}
|
||||
if (sprite.json.costumes) {
|
||||
collectSimple(sprite.json.costumes, `Costume for sprite ${sprite.name}`);
|
||||
collectSimple(sprite.json.costumes, dest, `Costume for sprite ${sprite.name}`);
|
||||
}
|
||||
if (sprite.json.sounds) {
|
||||
collectSimple(sprite.json.sounds, `Sound for sprite ${sprite.name}`);
|
||||
collectSimple(sprite.json.sounds, dest, `Sound for sprite ${sprite.name}`);
|
||||
}
|
||||
});
|
||||
return dest;
|
||||
|
@ -88,7 +88,7 @@ const fetchAsset = function (md5, callback) {
|
|||
};
|
||||
|
||||
const fetchAllAssets = function () {
|
||||
const allAssets = collectAssets();
|
||||
const allAssets = collectAssets(new Set());
|
||||
console.log(`Total library assets: ${allAssets.size}`);
|
||||
|
||||
async.forEachLimit(allAssets, NUM_SIMULTANEOUS_DOWNLOADS, fetchAsset, err => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue