From 9d3b03e16e122e1ede2a31e9c29ea3527b4756bf Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Thu, 29 Jun 2017 17:42:45 +0200 Subject: [PATCH] Fixed the 'VirtualFileSystem' --- .../v2/instances/VirtualFileSystem.d.ts | 3 +-- lib/manager/v2/instances/VirtualFileSystem.js | 16 ++------------ src/manager/v2/instances/VirtualFileSystem.ts | 21 ++----------------- 3 files changed, 5 insertions(+), 35 deletions(-) diff --git a/lib/manager/v2/instances/VirtualFileSystem.d.ts b/lib/manager/v2/instances/VirtualFileSystem.d.ts index f5e19921..19b28715 100644 --- a/lib/manager/v2/instances/VirtualFileSystem.d.ts +++ b/lib/manager/v2/instances/VirtualFileSystem.d.ts @@ -1,5 +1,5 @@ /// -import { LocalPropertyManager, LastModifiedDateInfo, FileSystemSerializer, OpenWriteStreamInfo, PropertyManagerInfo, OpenReadStreamInfo, IPropertyManager, LocalLockManager, CreationDateInfo, LockManagerInfo, SimpleCallback, ReturnCallback, ResourceType, ILockManager, ReadDirInfo, CreateInfo, DeleteInfo, FileSystem, SizeInfo, MoveInfo, TypeInfo } from '../fileSystem/export'; +import { LocalPropertyManager, LastModifiedDateInfo, FileSystemSerializer, OpenWriteStreamInfo, PropertyManagerInfo, OpenReadStreamInfo, IPropertyManager, LocalLockManager, CreationDateInfo, LockManagerInfo, SimpleCallback, ReturnCallback, ResourceType, ILockManager, ReadDirInfo, CreateInfo, DeleteInfo, FileSystem, SizeInfo, TypeInfo } from '../fileSystem/export'; import { Readable, Writable } from 'stream'; import { RequestContext } from '../../../server/v2/RequestContext'; import { Path } from '../Path'; @@ -40,7 +40,6 @@ export declare class VirtualFileSystem extends FileSystem { protected _delete(path: Path, ctx: DeleteInfo, callback: SimpleCallback): void; protected _openWriteStream(path: Path, ctx: OpenWriteStreamInfo, callback: ReturnCallback): void; protected _openReadStream(path: Path, ctx: OpenReadStreamInfo, callback: ReturnCallback): void; - protected _move(pathFrom: Path, pathTo: Path, ctx: MoveInfo, callback: ReturnCallback): void; protected _size(path: Path, ctx: SizeInfo, callback: ReturnCallback): void; protected _lockManager(path: Path, ctx: LockManagerInfo, callback: ReturnCallback): void; protected _propertyManager(path: Path, ctx: PropertyManagerInfo, callback: ReturnCallback): void; diff --git a/lib/manager/v2/instances/VirtualFileSystem.js b/lib/manager/v2/instances/VirtualFileSystem.js index d6c4c94d..4bc83456 100644 --- a/lib/manager/v2/instances/VirtualFileSystem.js +++ b/lib/manager/v2/instances/VirtualFileSystem.js @@ -112,10 +112,11 @@ var VirtualFileSystem = (function (_super) { callback(); }; VirtualFileSystem.prototype._delete = function (path, ctx, callback) { - var sPath = path.toString(); + var sPath = path.toString(true); for (var path_1 in this.resources) if (path_1.indexOf(sPath) === 0) delete this.resources[path_1]; + delete this.resources[path.toString()]; callback(); }; VirtualFileSystem.prototype._openWriteStream = function (path, ctx, callback) { @@ -137,19 +138,6 @@ var VirtualFileSystem = (function (_super) { return callback(Errors_1.Errors.ResourceNotFound); callback(null, new VirtualFileReadable(resource.content)); }; - VirtualFileSystem.prototype._move = function (pathFrom, pathTo, ctx, callback) { - var from = pathFrom.toString(); - var to = pathTo.toString(); - var existed = !!this.resources[to]; - var fromExists = !!this.resources[from]; - if (!fromExists) - return callback(Errors_1.Errors.ResourceNotFound); - if (existed && !ctx.overwrite) - return callback(Errors_1.Errors.ResourceAlreadyExists); - this.resources[to] = this.resources[from]; - delete this.resources[from]; - callback(null, existed); - }; VirtualFileSystem.prototype._size = function (path, ctx, callback) { var resource = this.resources[path.toString()]; if (!resource) diff --git a/src/manager/v2/instances/VirtualFileSystem.ts b/src/manager/v2/instances/VirtualFileSystem.ts index 21cf8703..9b58c378 100644 --- a/src/manager/v2/instances/VirtualFileSystem.ts +++ b/src/manager/v2/instances/VirtualFileSystem.ts @@ -158,10 +158,11 @@ export class VirtualFileSystem extends FileSystem protected _delete(path : Path, ctx : DeleteInfo, callback : SimpleCallback) : void { - const sPath = path.toString(); + const sPath = path.toString(true); for(const path in this.resources) if(path.indexOf(sPath) === 0) delete this.resources[path]; + delete this.resources[path.toString()]; callback(); } @@ -191,24 +192,6 @@ export class VirtualFileSystem extends FileSystem callback(null, new VirtualFileReadable(resource.content)); } - protected _move(pathFrom : Path, pathTo : Path, ctx : MoveInfo, callback : ReturnCallback) : void - { - const from = pathFrom.toString(); - const to = pathTo.toString(); - const existed = !!this.resources[to]; - const fromExists = !!this.resources[from]; - - if(!fromExists) - return callback(Errors.ResourceNotFound); - if(existed && !ctx.overwrite) - return callback(Errors.ResourceAlreadyExists); - - this.resources[to] = this.resources[from]; - delete this.resources[from]; - - callback(null, existed); - } - protected _size(path : Path, ctx : SizeInfo, callback : ReturnCallback) : void { const resource = this.resources[path.toString()];