Skip to content

Commit

Permalink
Merge pull request #110 from rodicm/master
Browse files Browse the repository at this point in the history
Create arbitrary doc id with push command, fixes #86
  • Loading branch information
benoitc committed Aug 30, 2017
2 parents 34aa134 + e527243 commit 0494de7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -15,3 +15,6 @@ erica
*.gz
distdir
erica.cmd

**~
**#
28 changes: 14 additions & 14 deletions src/erica_push.erl
Expand Up @@ -172,26 +172,26 @@ has_index_file(#couchapp{attachments=List}) ->
end, List).

id_from_path(Path, Config) ->
IdFile = filename:join(Path, "_id"),
case filelib:is_regular(IdFile) of
true ->
{ok, Bin} = file:read_file(IdFile),
[Id|_] = binary:split(Bin, [<<"\n">>, <<"\r\n">>], [trim]),
Id;
false ->
case erica_config:get(Config, docid) of
undefined ->
case erica_config:get(Config, docid) of
undefined ->
IdFile = filename:join(Path, "_id"),
case filelib:is_regular(IdFile) of
true ->
{ok, Bin} = file:read_file(IdFile),
[Id|_] = binary:split(Bin, [<<"\n">>, <<"\r\n">>], [trim]),
Id;
false ->
Fname = list_to_binary(filename:basename(Path)),
case erica_config:get(Config, is_ddoc) of
true ->
<<"_design/", Fname/binary>>;
false ->
Fname
end;
DocId ->
DocId
end
end.
end
end;
DocId ->
erlang:list_to_binary(DocId)
end.

couchapp_from_fs(#couchapp{ddoc_dir=DdocPath}=Couchapp) ->
Couchapp1 = attachments_from_fs(Couchapp),
Expand Down

0 comments on commit 0494de7

Please sign in to comment.