Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/acl-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,19 @@ class ACLChecker {

// Gets the ACL that applies to the resource
getNearestACL () {
const { resource } = this
let isContainer = false
// Create a cascade of reject handlers (one for each possible ACL)
let nearestACL = Promise.reject()
for (const acl of this.getPossibleACLs()) {
nearestACL = nearestACL.catch(() => new Promise((resolve, reject) => {
debug(`Check if ACL exists: ${acl}`)
this.fetch(acl, (err, graph) => {
if (err || !graph || !graph.length) {
if (err) debug(`Error reading ${acl}: ${err}`)
isContainer = true
reject(err)
} else {
const relative = resource.replace(acl.replace(/[^/]+$/, ''), './')
debug(`Using ACL ${acl} for ${relative}`)
resolve({ acl, graph, isContainer })
}
})
Expand Down
1 change: 0 additions & 1 deletion lib/handlers/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ function handler (req, res, next) {

// If request accepts the content-type we found
if (negotiator.mediaType([contentType])) {
debug('no translation necessary ' + contentType)
res.setHeader('Content-Type', contentType)
if (contentRange) {
var headers = { 'Content-Range': contentRange, 'Accept-Ranges': 'bytes', 'Content-Length': chunksize }
Expand Down
4 changes: 2 additions & 2 deletions lib/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ function addPermissions (req, res, next) {
getPermissionsFor(acl, session.userId, resource)
])
.then(([publicPerms, userPerms]) => {
debug.ACL(`Permissions for ${session.userId || '(none)'}: ${userPerms}`)
debug.ACL(`Permissions for public: ${publicPerms}`)
debug.ACL(`Permissions on ${resource} for ${session.userId || '(none)'}: ${userPerms}`)
debug.ACL(`Permissions on ${resource} for public: ${publicPerms}`)
res.set('WAC-Allow', `user="${userPerms}",public="${publicPerms}"`)
})
.then(next, next)
Expand Down
4 changes: 2 additions & 2 deletions lib/ldp.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,11 @@ class LDP {
}
stream
.on('error', function (err) {
debug.handlers('GET -- Read error:' + err.message)
debug.handlers(`GET -- error reading ${filename}: ${err.message}`)
return callback(error(err, "Can't create file " + err))
})
.on('open', function () {
debug.handlers('GET -- Read Start.')
debug.handlers(`GET -- Reading ${filename}`)
var contentType = mime.lookup(filename) || DEFAULT_CONTENT_TYPE
if (utils.hasSuffix(filename, ldp.turtleExtensions)) {
contentType = 'text/turtle'
Expand Down