-
Notifications
You must be signed in to change notification settings - Fork 10
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
Respect symlinks when reading static mocks #31
base: master
Are you sure you want to change the base?
Conversation
if fileExists(atPath: symLinkDestination) { | ||
return symLinkDestination | ||
} | ||
let basePath = (path as NSString).deletingLastPathComponent as NSString |
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.
I didn't understand why the last component of the path is being removed
let basePath = (path as NSString).deletingLastPathComponent as NSString | ||
let symlinkFullPath = basePath.appendingPathComponent(symLinkDestination) |
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.
Could you please explain why do we need these lines of code?
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.
It is used when symlink contains relative link to another file. So we reconstruct full path from current symlink path + relative path from symlink
4aa81cc
to
b6455e5
Compare
There was no option to save&repeat redirects in static mocks.
I suggested to make them with symbolic links from file to file.
The problem in current implementation that Vapor follows symlink when reading content of the file, but sets "content-length" header to symlink size. So, we always have incomplete response.
So I decided to check if the file is symlink and then follow it