Skip to content

Commit

Permalink
A 'FSManager.serialize(...)' returning 'undefined' or 'null' will lea…
Browse files Browse the repository at this point in the history
…d to skip the serialization of the resource
  • Loading branch information
AdrienCastex committed Jun 19, 2017
1 parent 05fd08c commit f5e06ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/manager/ISerializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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); });
Expand Down
9 changes: 8 additions & 1 deletion src/manager/ISerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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));
Expand Down

0 comments on commit f5e06ae

Please sign in to comment.