-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix regression, auto readlink on symlinks again #1830
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,12 @@ export interface UploadZipSpecification { | |
* The destination path in a zip for a file | ||
*/ | ||
destinationPath: string | ||
|
||
/** | ||
* Information about the file | ||
* https://nodejs.org/api/fs.html#class-fsstats | ||
*/ | ||
stats: fs.Stats | ||
} | ||
|
||
/** | ||
|
@@ -75,10 +81,11 @@ export function getUploadZipSpecification( | |
- file3.txt | ||
*/ | ||
for (let file of filesToZip) { | ||
if (!fs.existsSync(file)) { | ||
const stats = fs.lstatSync(file, {throwIfNoEntry: false}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mildly important part: we switched from
we'll use these stats to check |
||
if (!stats) { | ||
throw new Error(`File ${file} does not exist`) | ||
} | ||
if (!fs.statSync(file).isDirectory()) { | ||
if (!stats.isDirectory()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you have a symbolic link to a directory? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes you can!
I don't think so. As long as we know it's a directory that's all that matters. We add the symlink's path as the Directory symlinks don't need to be explicitly followed since our globber will do that for us when traversing the files. So as long as we know that it's a directory (symlink or not), that's all that matters. |
||
// Normalize and resolve, this allows for either absolute or relative paths to be used | ||
file = normalize(file) | ||
file = resolve(file) | ||
|
@@ -94,7 +101,8 @@ export function getUploadZipSpecification( | |
|
||
specification.push({ | ||
sourcePath: file, | ||
destinationPath: uploadPath | ||
destinationPath: uploadPath, | ||
stats | ||
}) | ||
} else { | ||
// Empty directory | ||
|
@@ -103,7 +111,8 @@ export function getUploadZipSpecification( | |
|
||
specification.push({ | ||
sourcePath: null, | ||
destinationPath: directoryPath | ||
destinationPath: directoryPath, | ||
stats | ||
}) | ||
} | ||
} | ||
|
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.
Since this is in the
src/internal
directory, does that mean this interface won't be used by consumers of this package?Would it make sense to export the minimal information we need rather than the entire
fs.Stats
interface?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 reason why I added the
fs.Stats
interface is if we eventually want to add file permissions, see this PR:The stats and mode can eventually be passed to the archiver library. I didn't want to do that yet to avoid additional changes.