Skip to content

Commit 43acf3f

Browse files
committed
Modified the 'FileSystem' class and the serialization method to skip allow non-serializable file system (skip the serialization of a fs if 'fs.serializer()' returns null/undefined)
1 parent 218d907 commit 43acf3f

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

lib/manager/v2/fileSystem/FileSystem.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export declare abstract class FileSystem implements ISerializableFileSystem {
1616
private __serializer;
1717
constructor(serializer: FileSystemSerializer);
1818
serializer(): FileSystemSerializer;
19+
setSerializer(serializer: FileSystemSerializer): void;
20+
doNotSerialize(): void;
1921
contextualize(ctx: RequestContext): ContextualFileSystem;
2022
resource(ctx: RequestContext, path: Path): Resource;
2123
fastExistCheckEx(ctx: RequestContext, _path: Path | string, errorCallback: SimpleCallback, callback: () => void): void;

lib/manager/v2/fileSystem/FileSystem.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ var FileSystem = (function () {
3838
FileSystem.prototype.serializer = function () {
3939
return this.__serializer;
4040
};
41+
FileSystem.prototype.setSerializer = function (serializer) {
42+
this.__serializer = serializer;
43+
};
44+
FileSystem.prototype.doNotSerialize = function () {
45+
this.__serializer = null;
46+
};
4147
FileSystem.prototype.contextualize = function (ctx) {
4248
return new ContextualFileSystem_1.ContextualFileSystem(this, ctx);
4349
};
@@ -780,7 +786,10 @@ var FileSystem = (function () {
780786
});
781787
};
782788
FileSystem.prototype.serialize = function (callback) {
783-
this.serializer().serialize(this, callback);
789+
var serializer = this.serializer();
790+
if (!serializer)
791+
return callback();
792+
serializer.serialize(this, callback);
784793
};
785794
return FileSystem;
786795
}());

lib/manager/v2/fileSystem/Serialization.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ function serialize(fileSystems, callback) {
88
.each(Object.keys(fileSystems), function (path, cb) {
99
var fs = fileSystems[path];
1010
var serializer = fs.serializer();
11+
if (!serializer)
12+
return cb(); // Skip serialization
1113
serializer.serialize(fs, function (e, data) {
1214
if (!e)
1315
result[path] = {

src/manager/v2/fileSystem/FileSystem.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ export abstract class FileSystem implements ISerializableFileSystem
5757
{
5858
return this.__serializer;
5959
}
60+
setSerializer(serializer : FileSystemSerializer)
61+
{
62+
this.__serializer = serializer;
63+
}
64+
doNotSerialize()
65+
{
66+
this.__serializer = null;
67+
}
6068

6169
contextualize(ctx : RequestContext) : ContextualFileSystem
6270
{
@@ -1036,7 +1044,11 @@ export abstract class FileSystem implements ISerializableFileSystem
10361044

10371045
serialize(callback : ReturnCallback<any>) : void
10381046
{
1039-
this.serializer().serialize(this, callback);
1047+
const serializer = this.serializer();
1048+
if(!serializer)
1049+
return callback();
1050+
1051+
serializer.serialize(this, callback);
10401052
}
10411053
}
10421054

src/manager/v2/fileSystem/Serialization.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export function serialize(fileSystems : UnserializedData, callback : ReturnCallb
4444
.each(Object.keys(fileSystems), (path, cb) => {
4545
const fs = fileSystems[path];
4646
const serializer = fs.serializer();
47+
if(!serializer)
48+
return cb(); // Skip serialization
49+
4750
serializer.serialize(fs, (e, data) => {
4851
if(!e)
4952
result[path] = {

0 commit comments

Comments
 (0)