zerovm/zerovm-cli — pull request #37 by larsbutler (2014-05-08 12:32:07+00:00)
Title: zvsh: don't nuke working dirs when saving rt files

If the user specifies a save dir for the runtime files (manifest,
nvram, etc.), don't nuke the entire directory! The original intention of
this was to ensure that the runtime files do not overwrite existing
files, but this is a destructive approach (and could result in the some
serious damage to the user's system). When I first encountered this bug,
I lost an entire git clone directory; luckily it was backed up a remote
repo, but I hope the risk here is clear.

So instead of nuking the directory, this change simply checks if the
runtime files we expect to create (nvram.1, manifest.1, etc.) exist. If
any exist, we halt. Otherwise, we continue writing to the target save
directory, whether it is empty or not.

The behavior when no save dir is specified does not change; we still
will create and cleanup a tempdir in this case.

This is a minimal fix for https://github.com/zerovm/zerovm-cli/issues/10.