-
Notifications
You must be signed in to change notification settings - Fork 152
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
Create target upfront #112
Conversation
lib/appdmg.js
Outdated
} else { | ||
next(null) | ||
} | ||
}) | ||
|
||
fs.open(global.target, 'wx', function (error) { |
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.
fs.writeFile
with empty string, as it is now the file descriptor is kept open
ping @cstruct 🦄 |
Open target with write and exclusive flag. This closes #65
a053863
to
0755d48
Compare
Rebased on master and issues have been fixed. |
Good job @cstruct 🙌 |
That last commit, won’t that open us up to leaving empty files behind? |
Yes it will... Adding the cleanup should be moved to the callback of the |
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.
RE-LGTM
lib/appdmg.js
Outdated
@@ -80,6 +80,14 @@ module.exports = exports = function (options) { | |||
fs.writeFile(global.target, '', { flag: 'wx' }, function (err) { | |||
if (err && err.code === 'EEXIST') return next(new Error('Target already exists')) | |||
|
|||
pipeline.addCleanupStep('unlink-target', 'Removing target image', function (next, hasErrored) { |
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.
err
could potentially be non-null here in which case the file won't exists. Maybe add if (err) return next(err)
before?
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.
actually, it might be that if fs.writeFile
returns an err
, we do not know if the file is there or not. In that case we should always unlink it, but ignore any ENOENT
errors...
Not super important to get this done now though, if you're short on time 👍
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.
Great!
Open target with write and exclusive flag.
This closes #65