better code: avoid double negation

Massimo Melina committed Jun 26, 2022 at 20:17 UTC f356d18cc88e7bb9334f28a7594db8a16406e74b
1 file changed +3 -3
server/src/middlewares.ts
+3 -3
@@ -65,13 +65,13 @@ export const serveGuiAndSharedFiles: Koa.Middleware = async (ctx, next) => {
65 const node = await urlToNode(path, ctx)
66 if (!node)
67 return ctx.status = 404
68 - const cantRead = !hasPermission(node, 'can_read', ctx)
68 + const canRead = hasPermission(node, 'can_read', ctx)
69 const isFolder = await nodeIsDirectory(node)
70 - if (!cantRead && !isFolder)
70 + if (canRead && !isFolder)
71 return node.source ? serveFileNode(node)(ctx,next)
72 : next()
73 ctx.set({ server:'HFS '+BUILD_TIMESTAMP })
74 - if (cantRead) {
74 + if (!canRead) {
75 ctx.status = cantReadStatusCode(node)
76 if (ctx.status === FORBIDDEN)
77 return