Generate md5s for uploaded assets

Without this, we were erroneously setting uploaded assets as clean, so they wouldn't be saved when uploaded from an .sb2/3 file.
This commit is contained in:
Ray Schamp committed 2019-01-02 11:46:47 -05:00
1 parent c449f14280
commit 80ff7e6756
3 files changed
+19 -12

No files matched your search

+16 -4
View File
@@ -43,8 +43,14 @@ const deserializeSound = function (sound, runtime, zip, assetFileName) {
storage.AssetType.Sound,
dataFormat,
data,
sound.assetId
));
null,
true
))
.then(asset => {
sound.asset = asset;
sound.assetId = asset.assetId;
sound.md5 = `${asset.assetId}.${asset.dataFormat}`;
});
};
/**
@@ -80,9 +86,12 @@ const deserializeCostume = function (costume, runtime, zip, assetFileName, textL
costume.asset.assetType,
costume.asset.dataFormat,
new Uint8Array(Object.keys(costume.asset.data).map(key => costume.asset.data[key])),
costume.asset.assetId
null,
true
)).then(asset => {
costume.asset = asset;
costume.assetId = asset.assetId;
costume.md5 = `${asset.assetId}.${asset.dataFormat}`;
});
}
@@ -140,10 +149,13 @@ const deserializeCostume = function (costume, runtime, zip, assetFileName, textL
// TODO eventually we want to map non-png's to their actual file types?
costumeFormat,
data,
assetId
null,
true
))
.then(asset => {
costume.asset = asset;
costume.assetId = asset.assetId;
costume.md5 = `${asset.assetId}.${asset.dataFormat}`;
})
]);
};
+2 -4
View File
@@ -497,10 +497,8 @@ const parseScratchObject = function (object, runtime, extensions, topLevel, zip)
// followed by the file ext
const assetFileName = `${soundSource.soundID}.${ext}`;
soundPromises.push(deserializeSound(sound, runtime, zip, assetFileName)
.then(asset => {
sound.asset = asset;
return loadSound(sound, runtime, sprite);
}));
.then(() => loadSound(sound, runtime, sprite))
);
}
}
+1 -4
View File
@@ -905,10 +905,7 @@ const parseScratchObject = function (object, runtime, extensions, zip) {
// any translation that needs to happen will happen in the process
// of building up the costume object into an sb3 format
return deserializeSound(sound, runtime, zip)
.then(asset => {
sound.asset = asset;
return loadSound(sound, runtime, sprite);
});
.then(() => loadSound(sound, runtime, sprite));
// Only attempt to load the sound after the deserialization
// process has been completed.
});