Repository: couchdb-fabric Updated Branches: refs/heads/master 03c927ba4 -> 34e7c2620
Don't create dbs doc if shard files fail for enametoolong reason COUCHDB-2821 Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/34e7c262 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/34e7c262 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/34e7c262 Branch: refs/heads/master Commit: 34e7c26208babcb15402e39b22516cf655d90510 Parents: 03c927b Author: Robert Newson <rnew...@apache.org> Authored: Tue Sep 22 13:10:23 2015 +0100 Committer: Robert Newson <rnew...@apache.org> Committed: Tue Sep 22 14:12:40 2015 +0100 ---------------------------------------------------------------------- src/fabric_db_create.erl | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/34e7c262/src/fabric_db_create.erl ---------------------------------------------------------------------- diff --git a/src/fabric_db_create.erl b/src/fabric_db_create.erl index dc1c0cc..63e6864 100644 --- a/src/fabric_db_create.erl +++ b/src/fabric_db_create.erl @@ -28,13 +28,19 @@ go(DbName, Options) -> {error, file_exists}; false -> {Shards, Doc} = generate_shard_map(DbName, Options), - case {create_shard_files(Shards), create_shard_db_doc(Doc)} of - {ok, {ok, Status}} -> - Status; - {file_exists, {ok, _}} -> - {error, file_exists}; - {_, Error} -> - Error + CreateShardResult = create_shard_files(Shards), + case CreateShardResult of + enametoolong -> + {error, {database_name_too_long, DbName}}; + _ -> + case {CreateShardResult, create_shard_db_doc(Doc)} of + {ok, {ok, Status}} -> + Status; + {file_exists, {ok, _}} -> + {error, file_exists}; + {_, Error} -> + Error + end end end; Error -> @@ -68,6 +74,8 @@ create_shard_files(Shards) -> try fabric_util:recv(Workers, #shard.ref, fun handle_message/3, Workers) of {error, file_exists} -> file_exists; + {error, enametoolong} -> + enametoolong; {timeout, DefunctWorkers} -> fabric_util:log_timeout(DefunctWorkers, "create_db"), {error, timeout}; @@ -77,6 +85,9 @@ create_shard_files(Shards) -> rexi_monitor:stop(RexiMon) end. +handle_message({error, enametoolong}, _, _) -> + {error, enametoolong}; + handle_message(file_exists, _, _) -> {error, file_exists};