diff --git a/lib/manager/ISerializer.js b/lib/manager/ISerializer.js index b6bb2f37..ef14ed00 100644 --- a/lib/manager/ISerializer.js +++ b/lib/manager/ISerializer.js @@ -53,6 +53,10 @@ function serialize(resource, callback) { resource.type(function (e, type) { var obj = new SerializedObject(resource.fsManager.uid, type); obj.data = resource.fsManager.serialize(resource, obj); + if (obj.data === undefined || obj.data === null) { + callback(null, null); + return; + } if (!type.isDirectory) { callback(null, obj); return; @@ -76,7 +80,8 @@ function serialize(resource, callback) { process.nextTick(function () { return callback(error, obj); }); return; } - obj.children.push(subObj); + if (subObj) + obj.children.push(subObj); --nb; if (nb === 0) process.nextTick(function () { return callback(null, obj); }); diff --git a/src/manager/ISerializer.ts b/src/manager/ISerializer.ts index 481865da..df0fc9b7 100644 --- a/src/manager/ISerializer.ts +++ b/src/manager/ISerializer.ts @@ -70,11 +70,17 @@ export function serialize(resource : IResource, callback : (error : Error, obj : const obj = new SerializedObject(resource.fsManager.uid, type); obj.data = resource.fsManager.serialize(resource, obj); + if(obj.data === undefined || obj.data === null) + { + callback(null, null); + return; + } if(!type.isDirectory) { callback(null, obj); return; } + resource.getChildren((e, children) => { process.nextTick(() => { if(e) @@ -99,7 +105,8 @@ export function serialize(resource : IResource, callback : (error : Error, obj : process.nextTick(() => callback(error, obj)); return; } - obj.children.push(subObj); + if(subObj) + obj.children.push(subObj); --nb; if(nb === 0) process.nextTick(() => callback(null, obj));