Skip to content

Commit

Permalink
The 'mimeType' method of the implemented resources now return the con…
Browse files Browse the repository at this point in the history
…tent type instead of the mime-type only
  • Loading branch information
AdrienCastex committed Jun 14, 2017
1 parent 787ed4e commit d1247af
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/resource/physical/PhysicalFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var PhysicalFile = (function (_super) {
});
};
PhysicalFile.prototype.mimeType = function (targetSource, callback) {
var mt = mimeTypes.lookup(this.realPath);
var mt = mimeTypes.contentType(this.realPath);
callback(null, mt ? mt : 'application/octet-stream');
};
PhysicalFile.prototype.size = function (targetSource, callback) {
Expand Down
2 changes: 1 addition & 1 deletion lib/resource/virtual/VirtualFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var VirtualFile = (function (_super) {
callback(null, new VirtualFileReadable(this.content));
};
VirtualFile.prototype.mimeType = function (targetSource, callback) {
var mt = mimeTypes.lookup(this.name);
var mt = mimeTypes.contentType(this.name);
callback(null, mt ? mt : 'application/octet-stream');
};
VirtualFile.prototype.size = function (targetSource, callback) {
Expand Down
2 changes: 1 addition & 1 deletion lib/resource/virtualStored/VirtualStoredFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var VirtualStoredFile = (function (_super) {
this.fsManager.contentManager.read(this.contentUid, callback);
};
VirtualStoredFile.prototype.mimeType = function (targetSource, callback) {
var mt = mimeTypes.lookup(this.name);
var mt = mimeTypes.contentType(this.name);
callback(null, mt ? mt : 'application/octet-stream');
};
VirtualStoredFile.prototype.size = function (targetSource, callback) {
Expand Down
5 changes: 5 additions & 0 deletions lib/server/webDAVServer/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ function addResourceTree(_rootResource, _resoureceTree, _callback) {
resoureceTree = _resoureceTree;
rootResource = _rootResource;
}
var cb = callback;
callback = function (e) {
if (cb)
cb(e);
};
if (resoureceTree.constructor === Array) {
var array = resoureceTree;
if (array.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/resource/physical/PhysicalFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class PhysicalFile extends PhysicalResource
}
mimeType(targetSource : boolean, callback : ReturnCallback<string>)
{
const mt = mimeTypes.lookup(this.realPath);
const mt = mimeTypes.contentType(this.realPath);
callback(null, mt ? mt as string : 'application/octet-stream');
}
size(targetSource : boolean, callback : ReturnCallback<number>)
Expand Down
2 changes: 1 addition & 1 deletion src/resource/virtual/VirtualFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class VirtualFile extends VirtualResource
}
mimeType(targetSource : boolean, callback : ReturnCallback<string>)
{
const mt = mimeTypes.lookup(this.name);
const mt = mimeTypes.contentType(this.name);
callback(null, mt ? mt as string : 'application/octet-stream');
}
size(targetSource : boolean, callback : ReturnCallback<number>)
Expand Down
2 changes: 1 addition & 1 deletion src/resource/virtualStored/VirtualStoredFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class VirtualStoredFile extends VirtualStoredResource
}
mimeType(targetSource : boolean, callback : ReturnCallback<string>)
{
const mt = mimeTypes.lookup(this.name);
const mt = mimeTypes.contentType(this.name);
callback(null, mt ? mt as string : 'application/octet-stream');
}
size(targetSource : boolean, callback : ReturnCallback<number>)
Expand Down
6 changes: 6 additions & 0 deletions src/server/webDAVServer/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export function addResourceTree(_rootResource : IResource | ResourceTreeNode, _r
rootResource = _rootResource as IResource;
}

const cb = callback;
callback = (e) => {
if(cb)
cb(e);
}

if(resoureceTree.constructor === Array)
{
const array = resoureceTree as any[];
Expand Down

0 comments on commit d1247af

Please sign in to comment.