From 12bdd45add01fe43e84d7e791898a554b6440486 Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Wed, 31 May 2017 12:53:27 +0200 Subject: [PATCH] Now return an error when requesting the size or mime-type of a virtual or physical folder --- lib/resource/physical/PhysicalFolder.js | 5 ++--- lib/resource/virtual/VirtualFolder.js | 5 ++--- src/resource/physical/PhysicalFolder.ts | 4 ++-- src/resource/virtual/VirtualFolder.ts | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/resource/physical/PhysicalFolder.js b/lib/resource/physical/PhysicalFolder.js index b981516d..b2e9c9fa 100644 --- a/lib/resource/physical/PhysicalFolder.js +++ b/lib/resource/physical/PhysicalFolder.js @@ -12,7 +12,6 @@ var __extends = (this && this.__extends) || (function () { Object.defineProperty(exports, "__esModule", { value: true }); var IResource_1 = require("../IResource"); var ResourceChildren_1 = require("../std/ResourceChildren"); -var StandardResource_1 = require("../std/StandardResource"); var PhysicalResource_1 = require("./PhysicalResource"); var Errors_1 = require("../../Errors"); var fs = require("fs"); @@ -76,10 +75,10 @@ var PhysicalFolder = (function (_super) { callback(Errors_1.Errors.InvalidOperation, null); }; PhysicalFolder.prototype.mimeType = function (targetSource, callback) { - callback(null, 'directory'); + callback(new Error('Cannot get the mime type of a folder type resource'), null); }; PhysicalFolder.prototype.size = function (targetSource, callback) { - StandardResource_1.StandardResource.sizeOfSubFiles(this, targetSource, callback); + callback(new Error('Cannot get the size of a folder type resource'), null); }; PhysicalFolder.prototype.addChild = function (resource, callback) { var _this = this; diff --git a/lib/resource/virtual/VirtualFolder.js b/lib/resource/virtual/VirtualFolder.js index ce8b7b72..5f5653a5 100644 --- a/lib/resource/virtual/VirtualFolder.js +++ b/lib/resource/virtual/VirtualFolder.js @@ -11,7 +11,6 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); var IResource_1 = require("../IResource"); -var StandardResource_1 = require("../std/StandardResource"); var ResourceChildren_1 = require("../std/ResourceChildren"); var VirtualResource_1 = require("./VirtualResource"); var Errors_1 = require("../../Errors"); @@ -32,10 +31,10 @@ var VirtualFolder = (function (_super) { callback(Errors_1.Errors.InvalidOperation, null); }; VirtualFolder.prototype.mimeType = function (targetSource, callback) { - callback(null, 'directory'); + callback(new Error('Cannot get the mime type of a folder type resource'), null); }; VirtualFolder.prototype.size = function (targetSource, callback) { - StandardResource_1.StandardResource.sizeOfSubFiles(this, targetSource, callback); + callback(new Error('Cannot get the size of a folder type resource'), null); }; VirtualFolder.prototype.addChild = function (resource, callback) { var _this = this; diff --git a/src/resource/physical/PhysicalFolder.ts b/src/resource/physical/PhysicalFolder.ts index a760252a..a2ea6460 100644 --- a/src/resource/physical/PhysicalFolder.ts +++ b/src/resource/physical/PhysicalFolder.ts @@ -92,11 +92,11 @@ export class PhysicalFolder extends PhysicalResource } mimeType(targetSource : boolean, callback : ReturnCallback) { - callback(null, 'directory'); + callback(new Error('Cannot get the mime type of a folder type resource'), null); } size(targetSource : boolean, callback : ReturnCallback) { - StandardResource.sizeOfSubFiles(this, targetSource, callback); + callback(new Error('Cannot get the size of a folder type resource'), null); } // ****************************** Children ****************************** // diff --git a/src/resource/virtual/VirtualFolder.ts b/src/resource/virtual/VirtualFolder.ts index 7b3ae61a..09b05c46 100644 --- a/src/resource/virtual/VirtualFolder.ts +++ b/src/resource/virtual/VirtualFolder.ts @@ -34,11 +34,11 @@ export class VirtualFolder extends VirtualResource } mimeType(targetSource : boolean, callback : ReturnCallback) { - callback(null, 'directory'); + callback(new Error('Cannot get the mime type of a folder type resource'), null); } size(targetSource : boolean, callback : ReturnCallback) { - StandardResource.sizeOfSubFiles(this, targetSource, callback); + callback(new Error('Cannot get the size of a folder type resource'), null); } // ****************************** Children ****************************** //