Skip to content

Commit

Permalink
Now return an error when requesting the size or mime-type of a virtua…
Browse files Browse the repository at this point in the history
…l or physical folder
  • Loading branch information
AdrienCastex committed May 31, 2017
1 parent aea18ee commit 12bdd45
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions lib/resource/physical/PhysicalFolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions lib/resource/virtual/VirtualFolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/resource/physical/PhysicalFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ export class PhysicalFolder extends PhysicalResource
}
mimeType(targetSource : boolean, callback : ReturnCallback<string>)
{
callback(null, 'directory');
callback(new Error('Cannot get the mime type of a folder type resource'), null);
}
size(targetSource : boolean, callback : ReturnCallback<number>)
{
StandardResource.sizeOfSubFiles(this, targetSource, callback);
callback(new Error('Cannot get the size of a folder type resource'), null);
}

// ****************************** Children ****************************** //
Expand Down
4 changes: 2 additions & 2 deletions src/resource/virtual/VirtualFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export class VirtualFolder extends VirtualResource
}
mimeType(targetSource : boolean, callback : ReturnCallback<string>)
{
callback(null, 'directory');
callback(new Error('Cannot get the mime type of a folder type resource'), null);
}
size(targetSource : boolean, callback : ReturnCallback<number>)
{
StandardResource.sizeOfSubFiles(this, targetSource, callback);
callback(new Error('Cannot get the size of a folder type resource'), null);
}

// ****************************** Children ****************************** //
Expand Down

0 comments on commit 12bdd45

Please sign in to comment.