diff --git a/lib/resource/IResource.d.ts b/lib/resource/IResource.d.ts index a0c41d46..75e3b924 100644 --- a/lib/resource/IResource.d.ts +++ b/lib/resource/IResource.d.ts @@ -27,11 +27,11 @@ export interface IResource { rename(newName: string, callback: Return2Callback): any; isSame(resource: IResource, callback: ReturnCallback): any; isOnTheSameFSWith(resource: IResource, callback: ReturnCallback): any; - append(data: Int8Array, callback: SimpleCallback): any; - write(data: Int8Array, callback: SimpleCallback): any; - read(callback: ReturnCallback): any; - mimeType(callback: ReturnCallback): any; - size(callback: ReturnCallback): any; + append(data: Int8Array, targetSource: boolean, callback: SimpleCallback): any; + write(data: Int8Array, targetSource: boolean, callback: SimpleCallback): any; + read(targetSource: boolean, callback: ReturnCallback): any; + mimeType(targetSource: boolean, callback: ReturnCallback): any; + size(targetSource: boolean, callback: ReturnCallback): any; getLocks(callback: ReturnCallback): any; setLock(lock: Lock, callback: SimpleCallback): any; removeLock(uuid: string, callback: ReturnCallback): any; diff --git a/lib/resource/physical/PhysicalFile.d.ts b/lib/resource/physical/PhysicalFile.d.ts index 8baca310..8c7339b0 100644 --- a/lib/resource/physical/PhysicalFile.d.ts +++ b/lib/resource/physical/PhysicalFile.d.ts @@ -6,11 +6,11 @@ export declare class PhysicalFile extends PhysicalResource { type(callback: ReturnCallback): void; create(callback: SimpleCallback): void; delete(callback: SimpleCallback): void; - append(data: Int8Array, callback: SimpleCallback): void; - write(data: Int8Array, callback: SimpleCallback): void; - read(callback: ReturnCallback): void; - mimeType(callback: ReturnCallback): void; - size(callback: ReturnCallback): void; + append(data: Int8Array, targetSource: boolean, callback: SimpleCallback): void; + write(data: Int8Array, targetSource: boolean, callback: SimpleCallback): void; + read(targetSource: boolean, callback: ReturnCallback): void; + mimeType(targetSource: boolean, callback: ReturnCallback): void; + size(targetSource: boolean, callback: ReturnCallback): void; addChild(resource: IResource, callback: SimpleCallback): void; removeChild(resource: IResource, callback: SimpleCallback): void; getChildren(callback: ReturnCallback): void; diff --git a/lib/resource/physical/PhysicalFile.js b/lib/resource/physical/PhysicalFile.js index bdb16f9c..42fe0737 100644 --- a/lib/resource/physical/PhysicalFile.js +++ b/lib/resource/physical/PhysicalFile.js @@ -42,7 +42,7 @@ var PhysicalFile = (function (_super) { _this.removeFromParent(callback); }); }; - PhysicalFile.prototype.append = function (data, callback) { + PhysicalFile.prototype.append = function (data, targetSource, callback) { var _this = this; fs.appendFile(this.realPath, data, function (e) { if (e) @@ -53,7 +53,7 @@ var PhysicalFile = (function (_super) { } }); }; - PhysicalFile.prototype.write = function (data, callback) { + PhysicalFile.prototype.write = function (data, targetSource, callback) { var _this = this; fs.writeFile(this.realPath, data, function (e) { if (e) @@ -64,14 +64,14 @@ var PhysicalFile = (function (_super) { } }); }; - PhysicalFile.prototype.read = function (callback) { + PhysicalFile.prototype.read = function (targetSource, callback) { fs.readFile(this.realPath, callback); }; - PhysicalFile.prototype.mimeType = function (callback) { + PhysicalFile.prototype.mimeType = function (targetSource, callback) { var mt = mimeTypes.lookup(this.realPath); callback(null, mt ? mt : 'application/octet-stream'); }; - PhysicalFile.prototype.size = function (callback) { + PhysicalFile.prototype.size = function (targetSource, callback) { fs.stat(this.realPath, function (e, s) { return callback(e, s ? s.size : null); }); }; PhysicalFile.prototype.addChild = function (resource, callback) { diff --git a/lib/resource/physical/PhysicalFolder.d.ts b/lib/resource/physical/PhysicalFolder.d.ts index 1271e6fc..ad70c82e 100644 --- a/lib/resource/physical/PhysicalFolder.d.ts +++ b/lib/resource/physical/PhysicalFolder.d.ts @@ -8,11 +8,11 @@ export declare class PhysicalFolder extends PhysicalResource { type(callback: ReturnCallback): void; create(callback: SimpleCallback): void; delete(callback: SimpleCallback): void; - append(data: Int8Array, callback: SimpleCallback): void; - write(data: Int8Array, callback: SimpleCallback): void; - read(callback: ReturnCallback): void; - mimeType(callback: ReturnCallback): void; - size(callback: ReturnCallback): void; + append(data: Int8Array, targetSource: boolean, callback: SimpleCallback): void; + write(data: Int8Array, targetSource: boolean, callback: SimpleCallback): void; + read(targetSource: boolean, callback: ReturnCallback): void; + mimeType(targetSource: boolean, callback: ReturnCallback): void; + size(targetSource: boolean, callback: ReturnCallback): void; addChild(resource: IResource, callback: SimpleCallback): void; removeChild(resource: IResource, callback: SimpleCallback): void; getChildren(callback: ReturnCallback): void; diff --git a/lib/resource/physical/PhysicalFolder.js b/lib/resource/physical/PhysicalFolder.js index e27cc3ad..939e25f5 100644 --- a/lib/resource/physical/PhysicalFolder.js +++ b/lib/resource/physical/PhysicalFolder.js @@ -69,20 +69,20 @@ var PhysicalFolder = (function (_super) { }); }); }; - PhysicalFolder.prototype.append = function (data, callback) { + PhysicalFolder.prototype.append = function (data, targetSource, callback) { callback(Errors_1.Errors.InvalidOperation); }; - PhysicalFolder.prototype.write = function (data, callback) { + PhysicalFolder.prototype.write = function (data, targetSource, callback) { callback(Errors_1.Errors.InvalidOperation); }; - PhysicalFolder.prototype.read = function (callback) { + PhysicalFolder.prototype.read = function (targetSource, callback) { callback(Errors_1.Errors.InvalidOperation, null); }; - PhysicalFolder.prototype.mimeType = function (callback) { + PhysicalFolder.prototype.mimeType = function (targetSource, callback) { callback(null, 'directory'); }; - PhysicalFolder.prototype.size = function (callback) { - StandardResource_1.StandardResource.sizeOfSubFiles(this, callback); + PhysicalFolder.prototype.size = function (targetSource, callback) { + StandardResource_1.StandardResource.sizeOfSubFiles(this, targetSource, callback); }; PhysicalFolder.prototype.addChild = function (resource, callback) { var _this = this; diff --git a/lib/resource/physical/PhysicalResource.d.ts b/lib/resource/physical/PhysicalResource.d.ts index cd1d90e8..9b146035 100644 --- a/lib/resource/physical/PhysicalResource.d.ts +++ b/lib/resource/physical/PhysicalResource.d.ts @@ -11,11 +11,11 @@ export declare abstract class PhysicalResource extends StandardResource { rename(newName: string, callback: Return2Callback): void; webName(callback: ReturnCallback): void; abstract type(callback: ReturnCallback): any; - abstract append(data: Int8Array, callback: SimpleCallback): any; - abstract write(data: Int8Array, callback: SimpleCallback): any; - abstract read(callback: ReturnCallback): any; - abstract mimeType(callback: ReturnCallback): any; - abstract size(callback: ReturnCallback): any; + abstract append(data: Int8Array, targetSource: boolean, callback: SimpleCallback): any; + abstract write(data: Int8Array, targetSource: boolean, callback: SimpleCallback): any; + abstract read(targetSource: boolean, callback: ReturnCallback): any; + abstract mimeType(targetSource: boolean, callback: ReturnCallback): any; + abstract size(targetSource: boolean, callback: ReturnCallback): any; abstract addChild(resource: IResource, callback: SimpleCallback): any; abstract removeChild(resource: IResource, callback: SimpleCallback): any; abstract getChildren(callback: ReturnCallback): any; diff --git a/lib/resource/std/RootResource.d.ts b/lib/resource/std/RootResource.d.ts index 8ba2affc..5f00d471 100644 --- a/lib/resource/std/RootResource.d.ts +++ b/lib/resource/std/RootResource.d.ts @@ -10,11 +10,11 @@ export declare class RootResource extends StandardResource { rename(newName: string, callback: Return2Callback): void; webName(callback: ReturnCallback): void; type(callback: ReturnCallback): void; - append(data: Int8Array, callback: SimpleCallback): void; - write(data: Int8Array, callback: SimpleCallback): void; - read(callback: ReturnCallback): void; - mimeType(callback: ReturnCallback): void; - size(callback: ReturnCallback): void; + append(data: Int8Array, targetSource: boolean, callback: SimpleCallback): void; + write(data: Int8Array, targetSource: boolean, callback: SimpleCallback): void; + read(targetSource: boolean, callback: ReturnCallback): void; + mimeType(targetSource: boolean, callback: ReturnCallback): void; + size(targetSource: boolean, callback: ReturnCallback): void; addChild(resource: IResource, callback: SimpleCallback): void; removeChild(resource: IResource, callback: SimpleCallback): void; getChildren(callback: ReturnCallback): void; diff --git a/lib/resource/std/RootResource.js b/lib/resource/std/RootResource.js index a4b1c0ef..f5d0d7e9 100644 --- a/lib/resource/std/RootResource.js +++ b/lib/resource/std/RootResource.js @@ -40,20 +40,20 @@ var RootResource = (function (_super) { RootResource.prototype.type = function (callback) { callback(null, IResource_1.ResourceType.Directory); }; - RootResource.prototype.append = function (data, callback) { + RootResource.prototype.append = function (data, targetSource, callback) { callback(Errors_1.Errors.InvalidOperation); }; - RootResource.prototype.write = function (data, callback) { + RootResource.prototype.write = function (data, targetSource, callback) { callback(Errors_1.Errors.InvalidOperation); }; - RootResource.prototype.read = function (callback) { + RootResource.prototype.read = function (targetSource, callback) { callback(Errors_1.Errors.InvalidOperation, null); }; - RootResource.prototype.mimeType = function (callback) { + RootResource.prototype.mimeType = function (targetSource, callback) { callback(null, 'directory'); }; - RootResource.prototype.size = function (callback) { - StandardResource_1.StandardResource.sizeOfSubFiles(this, callback); + RootResource.prototype.size = function (targetSource, callback) { + StandardResource_1.StandardResource.sizeOfSubFiles(this, targetSource, callback); }; RootResource.prototype.addChild = function (resource, callback) { var _this = this; diff --git a/lib/resource/std/StandardResource.d.ts b/lib/resource/std/StandardResource.d.ts index 6e342d44..f15678a2 100644 --- a/lib/resource/std/StandardResource.d.ts +++ b/lib/resource/std/StandardResource.d.ts @@ -4,7 +4,7 @@ import { LockKind } from '../lock/LockKind'; import { LockBag } from '../lock/LockBag'; import { Lock } from '../lock/Lock'; export declare abstract class StandardResource implements IResource { - static sizeOfSubFiles(resource: IResource, callback: ReturnCallback): void; + static sizeOfSubFiles(resource: IResource, targetSource: boolean, callback: ReturnCallback): void; properties: object; fsManager: FSManager; lockBag: LockBag; @@ -29,11 +29,11 @@ export declare abstract class StandardResource implements IResource { abstract delete(callback: SimpleCallback): any; abstract moveTo(parent: IResource, newName: string, override: boolean, callback: SimpleCallback): any; abstract rename(newName: string, callback: Return2Callback): any; - abstract append(data: Int8Array, callback: SimpleCallback): any; - abstract write(data: Int8Array, callback: SimpleCallback): any; - abstract read(callback: ReturnCallback): any; - abstract mimeType(callback: ReturnCallback): any; - abstract size(callback: ReturnCallback): any; + abstract append(data: Int8Array, targetSource: boolean, callback: SimpleCallback): any; + abstract write(data: Int8Array, targetSource: boolean, callback: SimpleCallback): any; + abstract read(targetSource: boolean, callback: ReturnCallback): any; + abstract mimeType(targetSource: boolean, callback: ReturnCallback): any; + abstract size(targetSource: boolean, callback: ReturnCallback): any; creationDate(callback: ReturnCallback): void; lastModifiedDate(callback: ReturnCallback): void; abstract webName(callback: ReturnCallback): any; diff --git a/lib/resource/std/StandardResource.js b/lib/resource/std/StandardResource.js index f8108526..0047e313 100644 --- a/lib/resource/std/StandardResource.js +++ b/lib/resource/std/StandardResource.js @@ -14,7 +14,7 @@ var StandardResource = (function () { this.parent = parent; this.dateLastModified = this.dateCreation; } - StandardResource.sizeOfSubFiles = function (resource, callback) { + StandardResource.sizeOfSubFiles = function (resource, targetSource, callback) { resource.getChildren(function (e, children) { if (e) { callback(e, null); @@ -39,7 +39,7 @@ var StandardResource = (function () { if (nb === 0) callback(null, size); } - children.forEach(function (c) { return c.size(go); }); + children.forEach(function (c) { return c.size(targetSource, go); }); }); }; StandardResource.prototype.isSame = function (resource, callback) { diff --git a/lib/resource/virtual/VirtualFile.d.ts b/lib/resource/virtual/VirtualFile.d.ts index 2eb0c160..97e3216f 100644 --- a/lib/resource/virtual/VirtualFile.d.ts +++ b/lib/resource/virtual/VirtualFile.d.ts @@ -5,11 +5,11 @@ export declare class VirtualFile extends VirtualResource { content: Int8Array; constructor(name: string, parent?: IResource, fsManager?: FSManager); type(callback: ReturnCallback): void; - append(data: Int8Array, callback: SimpleCallback): void; - write(data: Int8Array, callback: SimpleCallback): void; - read(callback: ReturnCallback): void; - mimeType(callback: ReturnCallback): void; - size(callback: ReturnCallback): void; + append(data: Int8Array, targetSource: boolean, callback: SimpleCallback): void; + write(data: Int8Array, targetSource: boolean, callback: SimpleCallback): void; + read(targetSource: boolean, callback: ReturnCallback): void; + mimeType(targetSource: boolean, callback: ReturnCallback): void; + size(targetSource: boolean, callback: ReturnCallback): void; addChild(resource: IResource, callback: SimpleCallback): void; removeChild(resource: IResource, callback: SimpleCallback): void; getChildren(callback: ReturnCallback): void; diff --git a/lib/resource/virtual/VirtualFile.js b/lib/resource/virtual/VirtualFile.js index 16addd9f..f9778038 100644 --- a/lib/resource/virtual/VirtualFile.js +++ b/lib/resource/virtual/VirtualFile.js @@ -24,7 +24,7 @@ var VirtualFile = (function (_super) { VirtualFile.prototype.type = function (callback) { callback(null, IResource_1.ResourceType.File); }; - VirtualFile.prototype.append = function (data, callback) { + VirtualFile.prototype.append = function (data, targetSource, callback) { var newContent = new Int8Array(this.content.length + data.length); for (var i = 0; i < this.content.length; ++i) newContent[i] = this.content[i]; @@ -34,19 +34,19 @@ var VirtualFile = (function (_super) { this.updateLastModified(); callback(null); }; - VirtualFile.prototype.write = function (data, callback) { + VirtualFile.prototype.write = function (data, targetSource, callback) { this.content = data; this.updateLastModified(); callback(null); }; - VirtualFile.prototype.read = function (callback) { + VirtualFile.prototype.read = function (targetSource, callback) { callback(null, this.content); }; - VirtualFile.prototype.mimeType = function (callback) { + VirtualFile.prototype.mimeType = function (targetSource, callback) { var mt = mimeTypes.lookup(this.name); callback(null, mt ? mt : 'application/octet-stream'); }; - VirtualFile.prototype.size = function (callback) { + VirtualFile.prototype.size = function (targetSource, callback) { callback(null, this.content.length); }; VirtualFile.prototype.addChild = function (resource, callback) { diff --git a/lib/resource/virtual/VirtualFolder.d.ts b/lib/resource/virtual/VirtualFolder.d.ts index 378f804b..3b4adefb 100644 --- a/lib/resource/virtual/VirtualFolder.d.ts +++ b/lib/resource/virtual/VirtualFolder.d.ts @@ -6,11 +6,11 @@ export declare class VirtualFolder extends VirtualResource { children: ResourceChildren; constructor(name: string, parent?: IResource, fsManager?: FSManager); type(callback: ReturnCallback): void; - append(data: Int8Array, callback: SimpleCallback): void; - write(data: Int8Array, callback: SimpleCallback): void; - read(callback: ReturnCallback): void; - mimeType(callback: ReturnCallback): void; - size(callback: ReturnCallback): void; + append(data: Int8Array, targetSource: boolean, callback: SimpleCallback): void; + write(data: Int8Array, targetSource: boolean, callback: SimpleCallback): void; + read(targetSource: boolean, callback: ReturnCallback): void; + mimeType(targetSource: boolean, callback: ReturnCallback): void; + size(targetSource: boolean, callback: ReturnCallback): void; addChild(resource: IResource, callback: SimpleCallback): void; removeChild(resource: IResource, callback: SimpleCallback): void; getChildren(callback: ReturnCallback): void; diff --git a/lib/resource/virtual/VirtualFolder.js b/lib/resource/virtual/VirtualFolder.js index e6ee4bb7..eeef9348 100644 --- a/lib/resource/virtual/VirtualFolder.js +++ b/lib/resource/virtual/VirtualFolder.js @@ -25,20 +25,20 @@ var VirtualFolder = (function (_super) { VirtualFolder.prototype.type = function (callback) { callback(null, IResource_1.ResourceType.Directory); }; - VirtualFolder.prototype.append = function (data, callback) { + VirtualFolder.prototype.append = function (data, targetSource, callback) { callback(Errors_1.Errors.InvalidOperation); }; - VirtualFolder.prototype.write = function (data, callback) { + VirtualFolder.prototype.write = function (data, targetSource, callback) { callback(Errors_1.Errors.InvalidOperation); }; - VirtualFolder.prototype.read = function (callback) { + VirtualFolder.prototype.read = function (targetSource, callback) { callback(Errors_1.Errors.InvalidOperation, null); }; - VirtualFolder.prototype.mimeType = function (callback) { + VirtualFolder.prototype.mimeType = function (targetSource, callback) { callback(null, 'directory'); }; - VirtualFolder.prototype.size = function (callback) { - StandardResource_1.StandardResource.sizeOfSubFiles(this, callback); + VirtualFolder.prototype.size = function (targetSource, callback) { + StandardResource_1.StandardResource.sizeOfSubFiles(this, targetSource, callback); }; VirtualFolder.prototype.addChild = function (resource, callback) { var _this = this; diff --git a/lib/resource/virtual/VirtualResource.d.ts b/lib/resource/virtual/VirtualResource.d.ts index 1e2da72c..20d5ad59 100644 --- a/lib/resource/virtual/VirtualResource.d.ts +++ b/lib/resource/virtual/VirtualResource.d.ts @@ -10,11 +10,11 @@ export declare abstract class VirtualResource extends StandardResource { rename(newName: string, callback: Return2Callback): void; webName(callback: ReturnCallback): void; abstract type(callback: ReturnCallback): any; - abstract append(data: Int8Array, callback: SimpleCallback): any; - abstract write(data: Int8Array, callback: SimpleCallback): any; - abstract read(callback: ReturnCallback): any; - abstract mimeType(callback: ReturnCallback): any; - abstract size(callback: ReturnCallback): any; + abstract append(data: Int8Array, targetSource: boolean, callback: SimpleCallback): any; + abstract write(data: Int8Array, targetSource: boolean, callback: SimpleCallback): any; + abstract read(targetSource: boolean, callback: ReturnCallback): any; + abstract mimeType(targetSource: boolean, callback: ReturnCallback): any; + abstract size(targetSource: boolean, callback: ReturnCallback): any; abstract addChild(resource: IResource, callback: SimpleCallback): any; abstract removeChild(resource: IResource, callback: SimpleCallback): any; abstract getChildren(callback: ReturnCallback): any; diff --git a/lib/server/commands/Copy.js b/lib/server/commands/Copy.js index 07d8d544..c4c5ef4f 100644 --- a/lib/server/commands/Copy.js +++ b/lib/server/commands/Copy.js @@ -51,8 +51,8 @@ function copy(arg, source, rDest, destination, callback) { next(); return; } - source.read(function (e, data) { return _(e, function () { - dest.write(data, function (e) { return _(e, next); }); + source.read(true, function (e, data) { return _(e, function () { + dest.write(data, true, function (e) { return _(e, next); }); }); }); function next() { if (!type.isDirectory) { diff --git a/lib/server/commands/Get.js b/lib/server/commands/Get.js index c80512a4..667607df 100644 --- a/lib/server/commands/Get.js +++ b/lib/server/commands/Get.js @@ -8,8 +8,9 @@ function default_1(arg, callback) { callback(); return; } - arg.requirePrivilege(['canRead'], r, function () { - r.read(function (e, c) { + var targetSource = arg.findHeader('source', 'F').toUpperCase() === 'T'; + arg.requirePrivilege(targetSource ? ['canRead', 'canSource'] : ['canRead'], r, function () { + r.read(targetSource, function (e, c) { if (e) arg.setCode(WebDAVRequest_1.HTTPCodes.MethodNotAllowed); else { diff --git a/lib/server/commands/Head.js b/lib/server/commands/Head.js index 10985f80..1d85dac3 100644 --- a/lib/server/commands/Head.js +++ b/lib/server/commands/Head.js @@ -8,8 +8,9 @@ function default_1(arg, callback) { callback(); return; } - arg.requirePrivilege(['canRead'], r, function () { - r.read(function (e, c) { + var targetSource = arg.findHeader('source', 'F').toUpperCase() === 'T'; + arg.requirePrivilege(targetSource ? ['canRead', 'canSource'] : ['canRead'], r, function () { + r.read(targetSource, function (e, c) { if (e) arg.setCode(WebDAVRequest_1.HTTPCodes.MethodNotAllowed); else diff --git a/lib/server/commands/Propfind.js b/lib/server/commands/Propfind.js index 334980cd..d63cf9e4 100644 --- a/lib/server/commands/Propfind.js +++ b/lib/server/commands/Propfind.js @@ -11,6 +11,7 @@ function default_1(arg, callback) { callback(); return; } + var targetSource = arg.findHeader('source', 'F').toUpperCase() === 'T'; var multistatus = XML_1.XML.createElement('D:multistatus', { 'xmlns:D': 'DAV:' }); @@ -19,29 +20,36 @@ function default_1(arg, callback) { addXMLInfo(resource, multistatus, function () { return done(multistatus); }); return; } - resource.getChildren(function (e, children) { - var nb = children.length + 1; - function nbOut(error) { - if (nb > 0 && error) { - nb = -1; - arg.setCode(WebDAVRequest_1.HTTPCodes.InternalServerError); - callback(); - return; + arg.requirePrivilege('canGetChildren', resource, function () { + resource.getChildren(function (e, children) { + var nb = children.length + 1; + function nbOut(error) { + if (nb > 0 && error) { + nb = -1; + arg.setCode(WebDAVRequest_1.HTTPCodes.InternalServerError); + callback(); + return; + } + --nb; + if (nb === 0) + done(multistatus); } - --nb; - if (nb === 0) - done(multistatus); - } - addXMLInfo(resource, multistatus, nbOut); - children.forEach(function (child) { - addXMLInfo(child, multistatus, nbOut); + addXMLInfo(resource, multistatus, nbOut); + children.forEach(function (child) { + addXMLInfo(child, multistatus, nbOut); + }); }); }); }); function addXMLInfo(resource, multistatus, callback) { var response = multistatus.ele('D:response'); var propstat = response.ele('D:propstat'); - arg.requireErPrivilege(['canMove'], resource, function (e, can) { + var privileges = [ + 'canGetCreationDate', 'canGetAvailableLocks', 'canGetLastModifiedDate', 'canGetMimeType', 'canGetProperties', 'canGetSize', 'canGetType', 'canGetWebName' + ]; + if (targetSource) + privileges.push('canSource'); + arg.requireErPrivilege(privileges, resource, function (e, can) { if (e) { propstat.ele('D:status').add('HTTP/1.1 ' + WebDAVRequest_1.HTTPCodes.InternalServerError + ' ' + http.STATUS_CODES[WebDAVRequest_1.HTTPCodes.InternalServerError]); callback(); @@ -116,12 +124,12 @@ function default_1(arg, callback) { resourcetype.ele('D:collection'); if (type.isFile) { nb += 2; - resource.mimeType(function (e, mimeType) { + resource.mimeType(targetSource, function (e, mimeType) { if (!e) prop.ele('D:getcontenttype').add(mimeType); nbOut(e); }); - resource.size(function (e, size) { + resource.size(targetSource, function (e, size) { if (!e) prop.ele('D:getcontentlength').add(size); nbOut(e); diff --git a/lib/server/commands/Put.js b/lib/server/commands/Put.js index 58e81773..2d4ccf14 100644 --- a/lib/server/commands/Put.js +++ b/lib/server/commands/Put.js @@ -38,11 +38,12 @@ function createResource(arg, callback, validCallback) { }); } function default_1(arg, callback) { + var targetSource = arg.findHeader('source', 'F').toUpperCase() === 'T'; arg.getResource(function (e, r) { if (arg.contentLength === 0) { if (r) { - arg.requirePrivilege(['canWrite'], r, function () { - r.write(new Buffer(0), function (e) { + arg.requirePrivilege(targetSource ? ['canSource', 'canWrite'] : ['canWrite'], r, function () { + r.write(new Buffer(0), targetSource, function (e) { if (e) arg.setCode(WebDAVRequest_1.HTTPCodes.InternalServerError); else @@ -61,7 +62,7 @@ function default_1(arg, callback) { var data_1 = new Buffer(arg.data); if (e) { createResource(arg, callback, function (r) { - r.write(data_1, function (e) { + r.write(data_1, targetSource, function (e) { if (e) arg.setCode(WebDAVRequest_1.HTTPCodes.InternalServerError); else @@ -71,8 +72,8 @@ function default_1(arg, callback) { }); return; } - arg.requirePrivilege(['canWrite'], r, function () { - r.write(data_1, function (e) { + arg.requirePrivilege(targetSource ? ['canSource', 'canWrite'] : ['canWrite'], r, function () { + r.write(data_1, targetSource, function (e) { if (e) arg.setCode(WebDAVRequest_1.HTTPCodes.InternalServerError); else diff --git a/lib/user/privilege/FakePrivilegeManager.d.ts b/lib/user/privilege/FakePrivilegeManager.d.ts index 58268d97..5d924fc0 100644 --- a/lib/user/privilege/FakePrivilegeManager.d.ts +++ b/lib/user/privilege/FakePrivilegeManager.d.ts @@ -5,6 +5,7 @@ export declare class FakePrivilegeManager extends SimplePrivilegeManager { canCreate: (arg: any, resource: any, callback: any) => any; canDelete: typeof hasNoWriteLock; canWrite: typeof hasNoWriteLock; + canSource: (arg: any, resource: any, callback: any) => any; canRead: (arg: any, resource: any, callback: any) => any; canListLocks: (arg: any, resource: any, callback: any) => any; canSetLock: typeof hasNoWriteLock; diff --git a/lib/user/privilege/FakePrivilegeManager.js b/lib/user/privilege/FakePrivilegeManager.js index ee8bb87f..ecca4a79 100644 --- a/lib/user/privilege/FakePrivilegeManager.js +++ b/lib/user/privilege/FakePrivilegeManager.js @@ -19,6 +19,7 @@ var FakePrivilegeManager = (function (_super) { _this.canCreate = function (arg, resource, callback) { return callback(null, true); }; _this.canDelete = IPrivilegeManager_1.hasNoWriteLock; _this.canWrite = IPrivilegeManager_1.hasNoWriteLock; + _this.canSource = function (arg, resource, callback) { return callback(null, true); }; _this.canRead = function (arg, resource, callback) { return callback(null, true); }; _this.canListLocks = function (arg, resource, callback) { return callback(null, true); }; _this.canSetLock = IPrivilegeManager_1.hasNoWriteLock; diff --git a/lib/user/privilege/IPrivilegeManager.d.ts b/lib/user/privilege/IPrivilegeManager.d.ts index b2f0c7fb..b815562b 100644 --- a/lib/user/privilege/IPrivilegeManager.d.ts +++ b/lib/user/privilege/IPrivilegeManager.d.ts @@ -2,7 +2,7 @@ import { MethodCallArgs } from '../../server/MethodCallArgs'; import { IResource } from '../../resource/IResource'; export declare type PrivilegeManagerCallback = (error: Error, hasAccess: boolean) => void; export declare type PrivilegeManagerMethod = (arg: MethodCallArgs, resource: IResource, callback: PrivilegeManagerCallback) => void; -export declare type BasicPrivilege = 'canCreate' | 'canDelete' | 'canMove' | 'canRename' | 'canAppend' | 'canWrite' | 'canRead' | 'canGetMimeType' | 'canGetSize' | 'canListLocks' | 'canSetLock' | 'canRemoveLock' | 'canGetAvailableLocks' | 'canGetLock' | 'canAddChild' | 'canRemoveChild' | 'canGetChildren' | 'canSetProperty' | 'canGetProperty' | 'canGetProperties' | 'canRemoveProperty' | 'canGetCreationDate' | 'canGetLastModifiedDate' | 'canGetWebName' | 'canGetType'; +export declare type BasicPrivilege = 'canCreate' | 'canDelete' | 'canMove' | 'canRename' | 'canAppend' | 'canWrite' | 'canRead' | 'canSource' | 'canGetMimeType' | 'canGetSize' | 'canListLocks' | 'canSetLock' | 'canRemoveLock' | 'canGetAvailableLocks' | 'canGetLock' | 'canAddChild' | 'canRemoveChild' | 'canGetChildren' | 'canSetProperty' | 'canGetProperty' | 'canGetProperties' | 'canRemoveProperty' | 'canGetCreationDate' | 'canGetLastModifiedDate' | 'canGetWebName' | 'canGetType'; export declare function requirePrivilege(privilege: string | BasicPrivilege | string[] | BasicPrivilege[], arg: MethodCallArgs, resource: IResource, callback: PrivilegeManagerCallback): void; export interface IPrivilegeManager { canCreate: PrivilegeManagerMethod; @@ -12,6 +12,7 @@ export interface IPrivilegeManager { canAppend: PrivilegeManagerMethod; canWrite: PrivilegeManagerMethod; canRead: PrivilegeManagerMethod; + canSource: PrivilegeManagerMethod; canGetMimeType: PrivilegeManagerMethod; canGetSize: PrivilegeManagerMethod; canListLocks: PrivilegeManagerMethod; diff --git a/lib/user/privilege/SimplePrivilegeManager.d.ts b/lib/user/privilege/SimplePrivilegeManager.d.ts index 1813aa98..363c7505 100644 --- a/lib/user/privilege/SimplePrivilegeManager.d.ts +++ b/lib/user/privilege/SimplePrivilegeManager.d.ts @@ -8,6 +8,7 @@ export declare abstract class SimplePrivilegeManager implements IPrivilegeManage canAppend: (arg: any, resource: any, callback: any) => void; abstract canWrite: PrivilegeManagerMethod; abstract canRead: PrivilegeManagerMethod; + abstract canSource: PrivilegeManagerMethod; canGetMimeType: (arg: any, resource: any, callback: any) => void; canGetSize: (arg: any, resource: any, callback: any) => void; abstract canListLocks: PrivilegeManagerMethod; diff --git a/src/resource/IResource.ts b/src/resource/IResource.ts index 83b6f9f3..f7b772e8 100644 --- a/src/resource/IResource.ts +++ b/src/resource/IResource.ts @@ -47,11 +47,11 @@ export interface IResource isOnTheSameFSWith(resource : IResource, callback : ReturnCallback) // ****************************** Content ****************************** // - append(data : Int8Array, callback : SimpleCallback) - write(data : Int8Array, callback : SimpleCallback) - read(callback : ReturnCallback) - mimeType(callback : ReturnCallback) - size(callback : ReturnCallback) + append(data : Int8Array, targetSource : boolean, callback : SimpleCallback) + write(data : Int8Array, targetSource : boolean, callback : SimpleCallback) + read(targetSource : boolean, callback : ReturnCallback) + mimeType(targetSource : boolean, callback : ReturnCallback) + size(targetSource : boolean, callback : ReturnCallback) // ****************************** Locks ****************************** // getLocks(callback : ReturnCallback) diff --git a/src/resource/physical/PhysicalFile.ts b/src/resource/physical/PhysicalFile.ts index 46c76035..6a39e218 100644 --- a/src/resource/physical/PhysicalFile.ts +++ b/src/resource/physical/PhysicalFile.ts @@ -41,7 +41,7 @@ export class PhysicalFile extends PhysicalResource } // ****************************** Content ****************************** // - append(data : Int8Array, callback : SimpleCallback) + append(data : Int8Array, targetSource : boolean, callback : SimpleCallback) { fs.appendFile(this.realPath, data, (e) => { if(e) @@ -53,7 +53,7 @@ export class PhysicalFile extends PhysicalResource } }); } - write(data : Int8Array, callback : SimpleCallback) + write(data : Int8Array, targetSource : boolean, callback : SimpleCallback) { fs.writeFile(this.realPath, data, (e) => { if(e) @@ -65,16 +65,16 @@ export class PhysicalFile extends PhysicalResource } }); } - read(callback : ReturnCallback) + read(targetSource : boolean, callback : ReturnCallback) { fs.readFile(this.realPath, callback); } - mimeType(callback : ReturnCallback) + mimeType(targetSource : boolean, callback : ReturnCallback) { const mt = mimeTypes.lookup(this.realPath); callback(null, mt ? mt as string : 'application/octet-stream'); } - size(callback : ReturnCallback) + size(targetSource : boolean, callback : ReturnCallback) { fs.stat(this.realPath, (e, s) => callback(e, s ? s.size : null)) } diff --git a/src/resource/physical/PhysicalFolder.ts b/src/resource/physical/PhysicalFolder.ts index 28751b97..7525c7ef 100644 --- a/src/resource/physical/PhysicalFolder.ts +++ b/src/resource/physical/PhysicalFolder.ts @@ -81,25 +81,25 @@ export class PhysicalFolder extends PhysicalResource } // ****************************** Content ****************************** // - append(data : Int8Array, callback : SimpleCallback) + append(data : Int8Array, targetSource : boolean, callback : SimpleCallback) { callback(Errors.InvalidOperation); } - write(data : Int8Array, callback : SimpleCallback) + write(data : Int8Array, targetSource : boolean, callback : SimpleCallback) { callback(Errors.InvalidOperation); } - read(callback : ReturnCallback) + read(targetSource : boolean, callback : ReturnCallback) { callback(Errors.InvalidOperation, null); } - mimeType(callback : ReturnCallback) + mimeType(targetSource : boolean, callback : ReturnCallback) { callback(null, 'directory'); } - size(callback : ReturnCallback) + size(targetSource : boolean, callback : ReturnCallback) { - StandardResource.sizeOfSubFiles(this, callback); + StandardResource.sizeOfSubFiles(this, targetSource, callback); } // ****************************** Children ****************************** // diff --git a/src/resource/physical/PhysicalResource.ts b/src/resource/physical/PhysicalResource.ts index 81f14eb2..cc6f1f62 100644 --- a/src/resource/physical/PhysicalResource.ts +++ b/src/resource/physical/PhysicalResource.ts @@ -76,11 +76,11 @@ export abstract class PhysicalResource extends StandardResource abstract type(callback : ReturnCallback) // ****************************** Content ****************************** // - abstract append(data : Int8Array, callback : SimpleCallback) - abstract write(data : Int8Array, callback : SimpleCallback) - abstract read(callback : ReturnCallback) - abstract mimeType(callback : ReturnCallback) - abstract size(callback : ReturnCallback) + abstract append(data : Int8Array, targetSource : boolean, callback : SimpleCallback) + abstract write(data : Int8Array, targetSource : boolean, callback : SimpleCallback) + abstract read(targetSource : boolean, callback : ReturnCallback) + abstract mimeType(targetSource : boolean, callback : ReturnCallback) + abstract size(targetSource : boolean, callback : ReturnCallback) // ****************************** Children ****************************** // abstract addChild(resource : IResource, callback : SimpleCallback) diff --git a/src/resource/std/RootResource.ts b/src/resource/std/RootResource.ts index b70380fc..eab42da1 100644 --- a/src/resource/std/RootResource.ts +++ b/src/resource/std/RootResource.ts @@ -45,25 +45,25 @@ export class RootResource extends StandardResource } // ****************************** Content ****************************** // - append(data : Int8Array, callback : SimpleCallback) + append(data : Int8Array, targetSource : boolean, callback : SimpleCallback) { callback(Errors.InvalidOperation) } - write(data : Int8Array, callback : SimpleCallback) + write(data : Int8Array, targetSource : boolean, callback : SimpleCallback) { callback(Errors.InvalidOperation) } - read(callback : ReturnCallback) + read(targetSource : boolean, callback : ReturnCallback) { callback(Errors.InvalidOperation, null) } - mimeType(callback : ReturnCallback) + mimeType(targetSource : boolean, callback : ReturnCallback) { callback(null, 'directory') } - size(callback : ReturnCallback) + size(targetSource : boolean, callback : ReturnCallback) { - StandardResource.sizeOfSubFiles(this, callback); + StandardResource.sizeOfSubFiles(this, targetSource, callback); } // ****************************** Children ****************************** // diff --git a/src/resource/std/StandardResource.ts b/src/resource/std/StandardResource.ts index 035daad7..9334f6b1 100644 --- a/src/resource/std/StandardResource.ts +++ b/src/resource/std/StandardResource.ts @@ -9,7 +9,7 @@ import { Lock } from '../lock/Lock' export abstract class StandardResource implements IResource { - static sizeOfSubFiles(resource : IResource, callback : ReturnCallback) + static sizeOfSubFiles(resource : IResource, targetSource : boolean, callback : ReturnCallback) { resource.getChildren((e, children) => { if(e) @@ -42,7 +42,7 @@ export abstract class StandardResource implements IResource callback(null, size); } - children.forEach((c) => c.size(go)) + children.forEach((c) => c.size(targetSource, go)) }) } @@ -181,11 +181,11 @@ export abstract class StandardResource implements IResource abstract rename(newName : string, callback : Return2Callback) // ****************************** Content ****************************** // - abstract append(data : Int8Array, callback : SimpleCallback) - abstract write(data : Int8Array, callback : SimpleCallback) - abstract read(callback : ReturnCallback) - abstract mimeType(callback : ReturnCallback) - abstract size(callback : ReturnCallback) + abstract append(data : Int8Array, targetSource : boolean, callback : SimpleCallback) + abstract write(data : Int8Array, targetSource : boolean, callback : SimpleCallback) + abstract read(targetSource : boolean, callback : ReturnCallback) + abstract mimeType(targetSource : boolean, callback : ReturnCallback) + abstract size(targetSource : boolean, callback : ReturnCallback) // ****************************** Std meta-data ****************************** // creationDate(callback : ReturnCallback) diff --git a/src/resource/virtual/VirtualFile.ts b/src/resource/virtual/VirtualFile.ts index 4c4507e9..ad888f62 100644 --- a/src/resource/virtual/VirtualFile.ts +++ b/src/resource/virtual/VirtualFile.ts @@ -22,7 +22,7 @@ export class VirtualFile extends VirtualResource } // ****************************** Content ****************************** // - append(data : Int8Array, callback : SimpleCallback) + append(data : Int8Array, targetSource : boolean, callback : SimpleCallback) { const newContent = new Int8Array(this.content.length + data.length) @@ -35,22 +35,22 @@ export class VirtualFile extends VirtualResource this.updateLastModified(); callback(null); } - write(data : Int8Array, callback : SimpleCallback) + write(data : Int8Array, targetSource : boolean, callback : SimpleCallback) { this.content = data; this.updateLastModified(); callback(null); } - read(callback : ReturnCallback) + read(targetSource : boolean, callback : ReturnCallback) { callback(null, this.content); } - mimeType(callback : ReturnCallback) + mimeType(targetSource : boolean, callback : ReturnCallback) { const mt = mimeTypes.lookup(this.name); callback(null, mt ? mt as string : 'application/octet-stream'); } - size(callback : ReturnCallback) + size(targetSource : boolean, callback : ReturnCallback) { callback(null, this.content.length); } diff --git a/src/resource/virtual/VirtualFolder.ts b/src/resource/virtual/VirtualFolder.ts index 5f0fb9b9..425fa9f8 100644 --- a/src/resource/virtual/VirtualFolder.ts +++ b/src/resource/virtual/VirtualFolder.ts @@ -23,25 +23,25 @@ export class VirtualFolder extends VirtualResource } // ****************************** Content ****************************** // - append(data : Int8Array, callback : SimpleCallback) + append(data : Int8Array, targetSource : boolean, callback : SimpleCallback) { callback(Errors.InvalidOperation); } - write(data : Int8Array, callback : SimpleCallback) + write(data : Int8Array, targetSource : boolean, callback : SimpleCallback) { callback(Errors.InvalidOperation); } - read(callback : ReturnCallback) + read(targetSource : boolean, callback : ReturnCallback) { callback(Errors.InvalidOperation, null); } - mimeType(callback : ReturnCallback) + mimeType(targetSource : boolean, callback : ReturnCallback) { callback(null, 'directory'); } - size(callback : ReturnCallback) + size(targetSource : boolean, callback : ReturnCallback) { - StandardResource.sizeOfSubFiles(this, callback); + StandardResource.sizeOfSubFiles(this, targetSource, callback); } // ****************************** Children ****************************** // diff --git a/src/resource/virtual/VirtualResource.ts b/src/resource/virtual/VirtualResource.ts index 1acfff5a..86098451 100644 --- a/src/resource/virtual/VirtualResource.ts +++ b/src/resource/virtual/VirtualResource.ts @@ -68,11 +68,11 @@ export abstract class VirtualResource extends StandardResource abstract type(callback : ReturnCallback) // ****************************** Content ****************************** // - abstract append(data : Int8Array, callback : SimpleCallback) - abstract write(data : Int8Array, callback : SimpleCallback) - abstract read(callback : ReturnCallback) - abstract mimeType(callback : ReturnCallback) - abstract size(callback : ReturnCallback) + abstract append(data : Int8Array, targetSource : boolean, callback : SimpleCallback) + abstract write(data : Int8Array, targetSource : boolean, callback : SimpleCallback) + abstract read(targetSource : boolean, callback : ReturnCallback) + abstract mimeType(targetSource : boolean, callback : ReturnCallback) + abstract size(targetSource : boolean, callback : ReturnCallback) // ****************************** Children ****************************** // abstract addChild(resource : IResource, callback : SimpleCallback) diff --git a/src/server/commands/Copy.ts b/src/server/commands/Copy.ts index d71c490d..29343651 100644 --- a/src/server/commands/Copy.ts +++ b/src/server/commands/Copy.ts @@ -70,8 +70,8 @@ function copy(arg : MethodCallArgs, source : IResource, rDest : IResource, desti return; } - source.read((e, data) => _(e, () => { - dest.write(data, (e) => _(e, next)) + source.read(true, (e, data) => _(e, () => { + dest.write(data, true, (e) => _(e, next)) })) function next() diff --git a/src/server/commands/Get.ts b/src/server/commands/Get.ts index 7d97a4a3..7b043472 100644 --- a/src/server/commands/Get.ts +++ b/src/server/commands/Get.ts @@ -11,8 +11,10 @@ export default function(arg : MethodCallArgs, callback) return; } - arg.requirePrivilege([ 'canRead' ], r, () => { - r.read((e, c) => { + const targetSource = arg.findHeader('source', 'F').toUpperCase() === 'T'; + + arg.requirePrivilege(targetSource ? [ 'canRead', 'canSource' ] : [ 'canRead' ], r, () => { + r.read(targetSource, (e, c) => { if(e) arg.setCode(HTTPCodes.MethodNotAllowed); else diff --git a/src/server/commands/Head.ts b/src/server/commands/Head.ts index b1582524..e04087a8 100644 --- a/src/server/commands/Head.ts +++ b/src/server/commands/Head.ts @@ -11,8 +11,10 @@ export default function(arg : MethodCallArgs, callback) return; } - arg.requirePrivilege([ 'canRead' ], r, () => { - r.read((e, c) => { + const targetSource = arg.findHeader('source', 'F').toUpperCase() === 'T'; + + arg.requirePrivilege(targetSource ? [ 'canRead', 'canSource' ] : [ 'canRead' ], r, () => { + r.read(targetSource, (e, c) => { if(e) arg.setCode(HTTPCodes.MethodNotAllowed) else diff --git a/src/server/commands/Propfind.ts b/src/server/commands/Propfind.ts index a411ad4e..1980ee84 100644 --- a/src/server/commands/Propfind.ts +++ b/src/server/commands/Propfind.ts @@ -1,5 +1,6 @@ import { HTTPCodes, MethodCallArgs, WebDAVRequest } from '../WebDAVRequest' import { IResource, ETag } from '../../resource/IResource' +import { BasicPrivilege } from '../../user/privilege/IPrivilegeManager' import { XML } from '../../helper/XML' import * as http from 'http' @@ -13,6 +14,8 @@ export default function(arg : MethodCallArgs, callback) return; } + const targetSource = arg.findHeader('source', 'F').toUpperCase() === 'T'; + const multistatus = XML.createElement('D:multistatus', { 'xmlns:D': 'DAV:' }) @@ -24,39 +27,46 @@ export default function(arg : MethodCallArgs, callback) return; } - resource.getChildren((e, children) => { - let nb = children.length + 1; + arg.requirePrivilege('canGetChildren', resource, () => { + resource.getChildren((e, children) => { + let nb = children.length + 1; - function nbOut(error) - { - if(nb > 0 && error) + function nbOut(error) { - nb = -1; - arg.setCode(HTTPCodes.InternalServerError); - callback(); - return; + if(nb > 0 && error) + { + nb = -1; + arg.setCode(HTTPCodes.InternalServerError); + callback(); + return; + } + + --nb; + if(nb === 0) + done(multistatus); } - --nb; - if(nb === 0) - done(multistatus); - } - - addXMLInfo(resource, multistatus, nbOut) - - children.forEach((child) => { - addXMLInfo(child, multistatus, nbOut) + addXMLInfo(resource, multistatus, nbOut) + + children.forEach((child) => { + addXMLInfo(child, multistatus, nbOut) + }) }) }) }) - function addXMLInfo(resource, multistatus, callback) + function addXMLInfo(resource : IResource, multistatus, callback) { const response = multistatus.ele('D:response') const propstat = response.ele('D:propstat') - arg.requireErPrivilege([ 'canMove' ], resource, (e, can) => { + const privileges : BasicPrivilege[] = [ + 'canGetCreationDate', 'canGetAvailableLocks', 'canGetLastModifiedDate', 'canGetMimeType', 'canGetProperties', 'canGetSize', 'canGetType', 'canGetWebName' + ]; + if(targetSource) + privileges.push('canSource'); + arg.requireErPrivilege(privileges, resource, (e, can) => { if(e) { propstat.ele('D:status').add('HTTP/1.1 ' + HTTPCodes.InternalServerError + ' ' + http.STATUS_CODES[HTTPCodes.InternalServerError]); @@ -156,12 +166,12 @@ export default function(arg : MethodCallArgs, callback) if(type.isFile) { nb += 2; - resource.mimeType((e, mimeType) => { + resource.mimeType(targetSource, (e, mimeType) => { if(!e) prop.ele('D:getcontenttype').add(mimeType) nbOut(e); }) - resource.size((e, size) => { + resource.size(targetSource, (e, size) => { if(!e) prop.ele('D:getcontentlength').add(size) nbOut(e); diff --git a/src/server/commands/Put.ts b/src/server/commands/Put.ts index ede76a4d..0b911b88 100644 --- a/src/server/commands/Put.ts +++ b/src/server/commands/Put.ts @@ -47,13 +47,15 @@ function createResource(arg : MethodCallArgs, callback, validCallback : (resourc export default function(arg : MethodCallArgs, callback) { + const targetSource = arg.findHeader('source', 'F').toUpperCase() === 'T'; + arg.getResource((e, r) => { if(arg.contentLength === 0) { // Create file if(r) { // Resource exists => empty it - arg.requirePrivilege([ 'canWrite' ], r, () => { - r.write(new Buffer(0), (e) => { + arg.requirePrivilege(targetSource ? [ 'canSource', 'canWrite' ] : [ 'canWrite' ], r, () => { + r.write(new Buffer(0), targetSource, (e) => { if(e) arg.setCode(HTTPCodes.InternalServerError) else @@ -76,7 +78,7 @@ export default function(arg : MethodCallArgs, callback) if(e) { // Resource not found createResource(arg, callback, (r) => { - r.write(data, (e) => { + r.write(data, targetSource, (e) => { if(e) arg.setCode(HTTPCodes.InternalServerError) else @@ -87,8 +89,8 @@ export default function(arg : MethodCallArgs, callback) return; } - arg.requirePrivilege([ 'canWrite' ], r, () => { - r.write(data, (e) => { + arg.requirePrivilege(targetSource ? [ 'canSource', 'canWrite' ] : [ 'canWrite' ], r, () => { + r.write(data, targetSource, (e) => { if(e) arg.setCode(HTTPCodes.InternalServerError) else diff --git a/src/user/privilege/FakePrivilegeManager.ts b/src/user/privilege/FakePrivilegeManager.ts index e58d4160..ac7182a9 100644 --- a/src/user/privilege/FakePrivilegeManager.ts +++ b/src/user/privilege/FakePrivilegeManager.ts @@ -14,6 +14,7 @@ export class FakePrivilegeManager extends SimplePrivilegeManager canCreate = (arg, resource, callback) => callback(null, true) canDelete = hasNoWriteLock canWrite = hasNoWriteLock + canSource = (arg, resource, callback) => callback(null, true) canRead = (arg, resource, callback) => callback(null, true) canListLocks = (arg, resource, callback) => callback(null, true) canSetLock = hasNoWriteLock diff --git a/src/user/privilege/IPrivilegeManager.ts b/src/user/privilege/IPrivilegeManager.ts index 7484f3e4..b53494a7 100644 --- a/src/user/privilege/IPrivilegeManager.ts +++ b/src/user/privilege/IPrivilegeManager.ts @@ -13,6 +13,7 @@ export type BasicPrivilege = | 'canAppend' | 'canWrite' | 'canRead' + | 'canSource' | 'canGetMimeType' | 'canGetSize' | 'canListLocks' @@ -59,6 +60,7 @@ export interface IPrivilegeManager canAppend : PrivilegeManagerMethod canWrite : PrivilegeManagerMethod canRead : PrivilegeManagerMethod + canSource : PrivilegeManagerMethod canGetMimeType : PrivilegeManagerMethod canGetSize : PrivilegeManagerMethod canListLocks : PrivilegeManagerMethod diff --git a/src/user/privilege/SimplePrivilegeManager.ts b/src/user/privilege/SimplePrivilegeManager.ts index 7e0cfa3f..adfa105a 100644 --- a/src/user/privilege/SimplePrivilegeManager.ts +++ b/src/user/privilege/SimplePrivilegeManager.ts @@ -20,6 +20,7 @@ export abstract class SimplePrivilegeManager implements IPrivilegeManager canAppend = (arg, resource, callback) => this.canWrite(arg, resource, callback) abstract canWrite : PrivilegeManagerMethod abstract canRead : PrivilegeManagerMethod + abstract canSource : PrivilegeManagerMethod canGetMimeType = (arg, resource, callback) => this.canRead(arg, resource, callback) canGetSize = (arg, resource, callback) => this.canRead(arg, resource, callback) abstract canListLocks : PrivilegeManagerMethod