Skip to content
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

Better error message when target directory isn't present #65

Closed
fritx opened this issue Aug 17, 2015 · 3 comments · Fixed by #112
Closed

Better error message when target directory isn't present #65

fritx opened this issue Aug 17, 2015 · 3 comments · Fixed by #112
Labels

Comments

@fritx
Copy link

fritx commented Aug 17, 2015

image

i found that it was the directory of the dmg target path didn't exist
i think it's a little strange with that outcoming message

how about we making sure the target directory is created, using mkdirp or something? :)

@LinusU
Copy link
Owner

LinusU commented Aug 17, 2015

As I said in #63, I'm not sure that we should create the output directory.

Hmm, I'm actually not sure if it should be appdmgs responsibility to make sure that the output folder exists. I don't know of any other unix commands that does it. E.g.

$ echo 'test' > /tmp/no-exists/my-file 
zsh: no such file or directory: /tmp/no-exists/my-file

$ touch /tmp/no-exists/my-file 
touch: /tmp/no-exists/my-file: No such file or directory

$ cp linus.jpg /tmp/no-exists/my-file
cp: /tmp/no-exists/my-file: No such file or directory

$ cat test.c 
int main(void) { return 0; }
$ gcc -o /tmp/no-exists/my-file test.c 
ld: can't open output file for writing: /tmp/no-exists/my-file, errno=2 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Now, I would like a much better error output thought. I think that the best way here is to try and create the file earlier on, and then raise helpful error if something goes wrong, and then tell hdiutil to overwrite the created empty file. This prevents ant race conditions that other approaches might have (e.g. checking if the directory exists, then starting hdiutil).

That being said, a better error message would be very appropriate.

@LinusU LinusU changed the title Error running hdiutil! Exit code was 1 Better error message when target directory isn't present Aug 17, 2015
@fritx
Copy link
Author

fritx commented Aug 17, 2015

oops sorry for the duplicated issue :)
entirely agreed. then how about checking the source/target before the hdiutil call?
i'm not sure it is good or not though

@LinusU
Copy link
Owner

LinusU commented Aug 17, 2015

I think that the best solution would be to start by creating target with the O_EXCL flag. That way we ensure that the file can be created; and error out early if something goes wrong.

@LinusU LinusU added the easy label May 22, 2016
cstruct pushed a commit that referenced this issue May 22, 2016
Open target with write and exclusive flag.
This closes #65
cstruct pushed a commit that referenced this issue Oct 22, 2017
Open target with write and exclusive flag.
This closes #65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants