C-Command Software Forum

Suggestion: Place temporary disk images in $TMPDIR instead of the destination folder

To possibly avoid any filename collisions, my humble suggestion is to maybe place disk images that are in the process of being created inside of the $TMPDIR folder, and then add a custom, guid-like text string to the end of it.

For example:


and if the filename is too long, truncate it (only for the temp file, though). For example, take a close look somewhat near the end of the filenames:


would get truncated to:


Hope this makes sense and proves to be somewhat useful.

Forgot to add:

And then, after creation, the disk image would be moved to its specified destination.

Collisions with what? DropDMG already checks to make sure it’s using a unique filename. Using $TMPDIR is problematic because that volume might not have as much space as the chosen destination drive and could leak sensitive data because it’s encrypted differently (or not at all).

Good points, I didn’t think of those. The only reason I brought up the idea was because I wasn’t sure if DropDMG could/would accidentally overwrite a file with _temp.xxx at the end of its filename.

Nope, DropDMG won’t overwrite any files. It will make sure it doesn’t create two temp files with the same name, and leave any temp files created by other apps/scripts in place.