From 3df40bb48deb2da126aa4dbbce4e5b7b05c30d8b Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Sat, 10 Jun 2017 19:55:16 +0200 Subject: [PATCH] Added the 'DAV:location' tag to the propfind response --- lib/server/commands/Propfind.js | 31 ++++++++++++------------- src/server/commands/Propfind.ts | 40 +++++++++++++++++---------------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/lib/server/commands/Propfind.js b/lib/server/commands/Propfind.js index 53058a58..3d6366ff 100644 --- a/lib/server/commands/Propfind.js +++ b/lib/server/commands/Propfind.js @@ -176,13 +176,13 @@ function default_1(arg, callback) { value: false }; } - mustDisplayTag('creationdate'); - mustDisplayTag('lockdiscovery'); - mustDisplayTag('getetag'); mustDisplayTag('getlastmodified'); + mustDisplayTag('lockdiscovery'); + mustDisplayTag('supportedlock'); + mustDisplayTag('creationdate'); mustDisplayTag('resourcetype'); mustDisplayTag('displayname'); - mustDisplayTag('supportedlock'); + mustDisplayTag('getetag'); function displayValue(values, fn) { if (values.constructor === String ? tags[values].value : values.some(function (n) { return tags[n].value; })) { ++nb; @@ -234,6 +234,7 @@ function default_1(arg, callback) { } var p = arg.fullUri(path).replace(' ', '%20'); response.ele('D:href').add(p.lastIndexOf('/') !== p.length - 1 && type.isDirectory ? p + '/' : p); + response.ele('D:location').ele('D:href').add(p); if (tags.resourcetype.value && type.isDirectory) tags.resourcetype.el.ele('D:collection'); if (type.isFile) { @@ -282,6 +283,17 @@ function default_1(arg, callback) { nbOut(); }); }); }); + displayValue(['getetag', 'getlastmodified'], function () { + resource.lastModifiedDate(function (e, lastModifiedDate) { return process.nextTick(function () { + if (!e) { + if (tags.getetag.value) + tags.getetag.el.add(IResource_1.ETag.createETag(lastModifiedDate)); + if (tags.getlastmodified.value) + tags.getlastmodified.el.add(new Date(lastModifiedDate).toUTCString()); + } + nbOut(e); + }); }); + }); ++nb; process.nextTick(function () { resource.getProperties(function (e, properties) { return process.nextTick(function () { @@ -299,17 +311,6 @@ function default_1(arg, callback) { nbOut(); }); }); }); - displayValue(['getetag', 'getlastmodified'], function () { - resource.lastModifiedDate(function (e, lastModifiedDate) { return process.nextTick(function () { - if (!e) { - if (tags.getetag.value) - tags.getetag.el.add(IResource_1.ETag.createETag(lastModifiedDate)); - if (tags.getlastmodified.value) - tags.getlastmodified.el.add(new Date(lastModifiedDate).toUTCString()); - } - nbOut(e); - }); }); - }); nbOut(); }); } diff --git a/src/server/commands/Propfind.ts b/src/server/commands/Propfind.ts index 77dd4d28..dd4a33ef 100644 --- a/src/server/commands/Propfind.ts +++ b/src/server/commands/Propfind.ts @@ -240,13 +240,14 @@ export default function(arg : MethodCallArgs, callback) value: false }; } - mustDisplayTag('creationdate') - mustDisplayTag('lockdiscovery') - mustDisplayTag('getetag') + mustDisplayTag('getlastmodified') + mustDisplayTag('lockdiscovery') + mustDisplayTag('supportedlock') + mustDisplayTag('creationdate') mustDisplayTag('resourcetype') mustDisplayTag('displayname') - mustDisplayTag('supportedlock') + mustDisplayTag('getetag') function displayValue(values : string[] | string, fn : () => void) { @@ -315,6 +316,7 @@ export default function(arg : MethodCallArgs, callback) const p = arg.fullUri(path).replace(' ', '%20'); response.ele('D:href').add(p.lastIndexOf('/') !== p.length - 1 && type.isDirectory ? p + '/' : p); + response.ele('D:location').ele('D:href').add(p); if(tags.resourcetype.value && type.isDirectory) tags.resourcetype.el.ele('D:collection') @@ -323,7 +325,7 @@ export default function(arg : MethodCallArgs, callback) { mustDisplayTag('getcontentlength') mustDisplayTag('getcontenttype') - + if(tags.getcontenttype.value) { ++nb; @@ -380,6 +382,20 @@ export default function(arg : MethodCallArgs, callback) })) }) + displayValue([ 'getetag', 'getlastmodified' ], () => + { + resource.lastModifiedDate((e, lastModifiedDate) => process.nextTick(() => { + if(!e) + { + if(tags.getetag.value) + tags.getetag.el.add(ETag.createETag(lastModifiedDate)) + if(tags.getlastmodified.value) + tags.getlastmodified.el.add(new Date(lastModifiedDate).toUTCString()) + } + nbOut(e); + })) + }) + ++nb; process.nextTick(() => { resource.getProperties((e, properties) => process.nextTick(() => { @@ -402,20 +418,6 @@ export default function(arg : MethodCallArgs, callback) })) }) - displayValue([ 'getetag', 'getlastmodified' ], () => - { - resource.lastModifiedDate((e, lastModifiedDate) => process.nextTick(() => { - if(!e) - { - if(tags.getetag.value) - tags.getetag.el.add(ETag.createETag(lastModifiedDate)) - if(tags.getlastmodified.value) - tags.getlastmodified.el.add(new Date(lastModifiedDate).toUTCString()) - } - nbOut(e); - })) - }) - nbOut(); }) }