-
Notifications
You must be signed in to change notification settings - Fork 22
Fix nasty 500 error on POST to /_config #21
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contributions and see some minor comments.
src/config.erl
Outdated
Event = {config_change, Sec, Key, Val, Persist}, | ||
gen_event:sync_notify(config_event, Event), | ||
{reply, ok, Config}; | ||
{error, _Else} -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use _ before Else
if _Else
is used in clause
src/config.erl
Outdated
Event = {config_change, Sec, Key, deleted, Persist}, | ||
gen_event:sync_notify(config_event, Event), | ||
{reply, ok, Config}; | ||
_Else -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use _ before Else if _Else is used in clause
end; | ||
|
||
handle_call({delete, Sec, Key, Persist, Reason}, _From, Config) -> | ||
true = ets:delete(?MODULE, {Sec,Key}), | ||
couch_log:notice("~p: [~s] ~s deleted for reason ~p", | ||
[?MODULE, Sec, Key, Reason]), | ||
case {Persist, Config#config.write_filename} of | ||
ConfigDeleteReturn = case {Persist, Config#config.write_filename} of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on delete scenario
test/config_tests.erl
Outdated
@@ -299,6 +299,45 @@ config_notifier_behaviour_test_() -> | |||
}. | |||
|
|||
|
|||
config_access_right_test_() -> | |||
{ | |||
"Config file access right tests", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow with other test description and what about Test config file access right
?
@jiangphcn you'll need to push a trivial commit to this branch to force travis to re-run the test. |
00dddea
to
1cc8bdf
Compare
@wohali yes, just doing this with @wenli200133 and rebased the change on #22 |
CI is happy now :-) |
I will merge this PR if there is no additional comments. @wohali |
You're the one who gave it a +1 @jiangphcn ;) I'm not reviewing the code here, just helping you with the process! |
@wohali thanks for your help on process. Just merged |
Overview
When the ini config file is read only, function of
file:write_file(File, NewFileContents).
doesn't returnok
, so for here we should handle the return error scenario.Testing recommendations
Related Issues or Pull Requests
This PR and apache/couchdb#1717 is for fixing issue of apache/couchdb#1380
PR apache/couchdb#1717 is dependent on this.
so this PR should be first merged into master, then apache/couchdb#1717 can pick it up.
Checklist