diff options
| author | jmoenig <jens@moenig.org> | 2013-10-10 11:09:29 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-10-10 11:09:29 +0200 |
| commit | 027388029f3a2b9e15b5552fce4cc01ea308feab (patch) | |
| tree | 98444333c80d9f254be5e481dc91b3f78d253f51 | |
| parent | 24476a644e18b526f09dab730a09b88a6e501a5a (diff) | |
| download | snap-027388029f3a2b9e15b5552fce4cc01ea308feab.tar.gz snap-027388029f3a2b9e15b5552fce4cc01ea308feab.zip | |
"sanity check" for cloud-saving mechanism
errors if the serialized project data is corrupt and cannot be parsed
as XML, addresses #203, #200, #171. I'm hoping that this might provide
us a clue whether the corruption is happening in Snap's marshalling or
on the backend side
| -rw-r--r-- | cloud.js | 20 | ||||
| -rwxr-xr-x | history.txt | 4 |
2 files changed, 23 insertions, 1 deletions
@@ -29,7 +29,7 @@ /*global modules, IDE_Morph, SnapSerializer, hex_sha512, alert, nop*/ -modules.cloud = '2013-September-17'; +modules.cloud = '2013-October-10'; // Global stuff @@ -356,6 +356,24 @@ Cloud.prototype.saveProject = function (ide, callBack, errorCall) { ide.serializer.isCollectingMedia = false; ide.serializer.flushMedia(); + // check if serialized data can be parsed back again + try { + ide.serializer.parse(pdata); + } catch (err) { + ide.showMessage('Serialization of program data failed:\n' + err); + throw new Error('Serialization of program data failed:\n' + err); + } + if (media !== null) { + try { + ide.serializer.parse(media); + } catch (err) { + ide.showMessage('Serialization of media failed:\n' + err); + throw new Error('Serialization of media failed:\n' + err); + } + } + ide.serializer.isCollectingMedia = false; + ide.serializer.flushMedia(); + myself.reconnect( function () { myself.callService( diff --git a/history.txt b/history.txt index 4d26412..7452005 100755 --- a/history.txt +++ b/history.txt @@ -1950,3 +1950,7 @@ ______ 131009 ------ * Theads: added a variant for linked lists to the experimental MAP primitive reporter + +131010 +------ +* Cloud: added "sanity check" to cloud-saving mechanism that errors if the serialized project data is corrupt and cannot be parsed as XML, addresses #203, #200, #171 |
