Skip to content

Commit

Permalink
Added the 'DAV:location' tag to the propfind response
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Jun 10, 2017
1 parent 90835d3 commit 3df40bb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 34 deletions.
31 changes: 16 additions & 15 deletions lib/server/commands/Propfind.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 () {
Expand All @@ -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();
});
}
Expand Down
40 changes: 21 additions & 19 deletions src/server/commands/Propfind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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')
Expand All @@ -323,7 +325,7 @@ export default function(arg : MethodCallArgs, callback)
{
mustDisplayTag('getcontentlength')
mustDisplayTag('getcontenttype')

if(tags.getcontenttype.value)
{
++nb;
Expand Down Expand Up @@ -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(() => {
Expand All @@ -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();
})
}
Expand Down

0 comments on commit 3df40bb

Please sign in to comment.