-
Notifications
You must be signed in to change notification settings - Fork 50
feat(ipfs-car): avoid recursive writes #175
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
base: main
Are you sure you want to change the base?
Conversation
fix #174 if output file exists in source path, just overwrite it, but don't include it in the packed car file
autonome
left a comment
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.
looks good, thanks! added a couple of minor non-blocking suggestions
| let fullOutputPath | ||
| if (opts.output) { | ||
| fullOutputPath = path.resolve(opts.output) | ||
| } |
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.
| let fullOutputPath | |
| if (opts.output) { | |
| fullOutputPath = path.resolve(opts.output) | |
| } | |
| const fullOutputPath = opts.output !== null ? path.resolve(opts.output) : null; |
- stricter check
- remove unnecessary modifiableness
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'm not convinced this will work. It's worth checking but I don't think opts.output is ever null. It might be undefined or the empty string.
| ? await filesFromPaths(paths, { | ||
| hidden, | ||
| filter: (filePath) => { | ||
| const include = !fullOutputPath || filePath !== fullOutputPath |
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.
| const include = !fullOutputPath || filePath !== fullOutputPath | |
| const include = fullOutputPath !== null || filePath !== fullOutputPath |
- stricter check
alanshaw
left a comment
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 don't have super strong opinions here but I think I'd prefer an error. If I output to a CAR file in the source directory that I wanted to keep, then that CAR is now not in the new CAR and is no longer in the source directory (it got overwritten). It is lost forever.
agree that it's better to bail than to make an assumption that results in permanent data loss. however, the caller has themselves pointed to the output file. if they wanted to keep that file, why would they have made it the output file? |
|
People make mistakes! |
ok first do no harm then, bail loudly ftw low priority would be a --force or --overwrite for the not-a-mistake case |
fix #174
if output file exists in source path, just overwrite it, but don't include it in the packed car file
requires storacha/files-from-path#46