-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(server): asset serve files #2052
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
7e67394
to
6c29abc
Compare
@@ -264,81 +247,18 @@ export class AssetService { | |||
res: Res, | |||
headers: Record<string, string>, | |||
) { | |||
const allowOriginalFile = !authUser.isPublicUser || authUser.isAllowDownload; | |||
const allowOriginalFile = !!(!authUser.isPublicUser || authUser.isAllowDownload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the different between the old vs the new logic here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old logic resulted in a type of boolean | undefined
. That is OK because undefined
also is falsy. However, it's now being passed into a function that has a type boolean
, so this (!!
) is just a fancy way to turn undefined
into false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change in logic, just a coercion of type to align with the new method I added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and everything looks good!
There was a lot of duplicate code related to reading and returning a file (etag check, file readability check, setting headers, creating read stream, etc.). This has been refactored so there's no more duplicate code related to reading and streaming files.