rethinkdb/rethinkdb — pull request #1545 by cxmcc (2013-10-15 11:31:05+00:00)
Title: consider directory is new if 'metadata' does not exists

"rethinkdb -d /empty/dir" fails with error messages

with error message:
error: Inaccessible database file: "/the/empty/dir/metadata": No such file or directory
Some possible reasons:
- the database file couldn't be created or opened for reading and writing
- the user which was used to start the database is not an owner of the file

Similarly "rethinkdb create -d /empty/dir" also fails because creating an db on an existing directory is forbidden.

However I think these actions should be allowed. What I think users will normally do is to create an empty dir, and then let DB initialize it. (What I am doing all the time with mysql, mongo, etc)

This commit tries to ensure this behavior: Detect whether 'metadata' is in the directory, consider the directory is not initialized as a rethinkdb instance if 'metadata' does not exist, and then start to initialize it if needed.