1
0
mirror of https://github.com/SuperBFG7/ympd synced 2025-03-04 10:38:18 +00:00

Write statefile first to tmpfile

This commit is contained in:
jcorporation 2018-06-24 19:05:38 +01:00
parent b6d1985d38
commit 98d20cb08c

View File

@ -75,7 +75,10 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
switch(cmd_id) { switch(cmd_id) {
case MPD_API_SET_SETTINGS: case MPD_API_SET_SETTINGS:
json_scanf(msg.p, msg.len, "{ data: { notificationWeb: %d, notificationPage: %d} }", &state.a, &state.b); json_scanf(msg.p, msg.len, "{ data: { notificationWeb: %d, notificationPage: %d} }", &state.a, &state.b);
json_fprintf(mpd.statefile, "{ notificationWeb: %d, notificationPage: %d}", state.a, state.b); char tmpfile[200];
snprintf(tmpfile,200,"%s.tmp",mpd.statefile);
json_fprintf(tmpfile, "{ notificationWeb: %d, notificationPage: %d}", state.a, state.b);
rename(tmpfile,mpd.statefile);
je = json_scanf(msg.p, msg.len, "{ data: { random:%u } }", &uint_buf1); je = json_scanf(msg.p, msg.len, "{ data: { random:%u } }", &uint_buf1);
if (je == 1) if (je == 1)