From c81190d2ba6ef1d5283fa2882ccd4c0dd361ddb1 Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Tue, 6 Jun 2017 16:54:30 +0200 Subject: [PATCH] Fixed a bug when serializing a VirtualStoredFile having a content length of 0 --- lib/manager/VirtualStoredFSManager.js | 6 +++--- src/manager/VirtualStoredFSManager.ts | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/manager/VirtualStoredFSManager.js b/lib/manager/VirtualStoredFSManager.js index 26895217..22cb3802 100644 --- a/lib/manager/VirtualStoredFSManager.js +++ b/lib/manager/VirtualStoredFSManager.js @@ -130,10 +130,10 @@ var VirtualStoredFSManager = (function () { properties: resource.properties }; result.name = resource.name; - if (resource.len) + if (resource.contentUid) { result.len = resource.len; - if (resource.contentUid) result.contentUid = resource.contentUid; + } return result; }; VirtualStoredFSManager.prototype.unserialize = function (data, obj) { @@ -146,7 +146,7 @@ var VirtualStoredFSManager = (function () { } if (obj.type.isFile) { var rs = new VirtualStoredFile_1.VirtualStoredFile(data.name, null, this); - rs.len = data.len; + rs.len = data.len === undefined ? 0 : data.len; rs.contentUid = data.contentUid; rs.dateCreation = data.dateCreation; rs.dateLastModified = data.dateLastModified; diff --git a/src/manager/VirtualStoredFSManager.ts b/src/manager/VirtualStoredFSManager.ts index 96e267ee..4b2665cc 100644 --- a/src/manager/VirtualStoredFSManager.ts +++ b/src/manager/VirtualStoredFSManager.ts @@ -182,10 +182,11 @@ export class VirtualStoredFSManager implements FSManager }; result.name = resource.name; - if(resource.len) - result.len = resource.len; if(resource.contentUid) + { + result.len = resource.len; result.contentUid = resource.contentUid; + } return result; } @@ -203,7 +204,7 @@ export class VirtualStoredFSManager implements FSManager if(obj.type.isFile) { const rs = new VirtualStoredFile(data.name, null, this); - rs.len = data.len; + rs.len = data.len === undefined ? 0 : data.len; rs.contentUid = data.contentUid; rs.dateCreation = data.dateCreation; rs.dateLastModified = data.dateLastModified;