Skip to content

Commit 17e28b2

Browse files
committed
Make sure to save assets before sending them to the backpack
This prevents assets from existing in the backpack server without also existing in the asset server.
1 parent 7fcbae6 commit 17e28b2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/containers/backpack.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,15 @@ class Backpack extends React.Component {
8383
}
8484
handleDrop (dragInfo) {
8585
let payloader = null;
86+
let presaveAsset = null;
8687
switch (dragInfo.dragType) {
8788
case DragConstants.COSTUME:
8889
payloader = costumePayload;
90+
presaveAsset = dragInfo.asset;
8991
break;
9092
case DragConstants.SOUND:
9193
payloader = soundPayload;
94+
presaveAsset = dragInfo.asset;
9295
break;
9396
case DragConstants.SPRITE:
9497
payloader = spritePayload;
@@ -102,6 +105,14 @@ class Backpack extends React.Component {
102105
// Creating the payload is async, so set loading before starting
103106
this.setState({loading: true}, () => {
104107
payloader(dragInfo.payload, this.props.vm)
108+
.then(payload => {
109+
// Force the asset to save to the asset server before storing in backpack
110+
// Ensures any asset present in the backpack is also on the asset server
111+
if (presaveAsset && !presaveAsset.clean) {
112+
return storage.store(presaveAsset).then(() => payload);
113+
}
114+
return payload;
115+
})
105116
.then(payload => saveBackpackObject({
106117
host: this.props.host,
107118
token: this.props.token,

0 commit comments

Comments
 (0)