jcs
/subtext
/amendments
/461
sysop: bile_flush after touching anything in the config
Also don't touch db->folders or db->boards when saving, we're going
to re-cache everything in them anyway.
jcs made amendment 461 about 1 year ago
--- sysop.c Thu Apr 6 13:54:43 2023
+++ sysop.c Thu Apr 6 15:23:24 2023
@@ -123,6 +123,7 @@ sysop_edit_settings(struct session *s)
memcpy(&old_config, &db->config, sizeof(db->config));
memcpy(&db->config, new_config, sizeof(db->config));
db_config_save(db);
+ bile_flush(db->bile, true);
memcpy(&db->config, &old_config, sizeof(db->config));
session_logf(s, "Changed BBS settings");
@@ -207,6 +208,7 @@ sysop_edit_boards(struct session *s)
continue;
}
bile_close(new_board_bile);
+ bile_flush(db->bile, true);
db_cache_boards(db);
session_logf(s, "Created new board %ld: %s", new_board->id,
@@ -252,12 +254,10 @@ edit_board:
board->id, board->name);
db_board_delete(db, board);
+ bile_flush(db->bile, true);
db_cache_boards(db);
break;
case 0:
- memcpy(&db->boards[bn - 1], new_board,
- sizeof(struct board));
-
ret = bile_marshall_object(db->bile, board_object_fields,
nboard_object_fields, new_board, &data, &size);
if (ret != 0 || size == 0)
@@ -267,6 +267,7 @@ edit_board:
data, size) != size)
panic("save of board failed: %d", bile_error(db->bile));
xfree(&data);
+ bile_flush(db->bile, true);
session_logf(s, "Saved changes to board %ld: %s",
new_board->id, new_board->name);
@@ -360,6 +361,7 @@ sysop_edit_folders(struct session *s)
continue;
}
bile_close(new_folder_bile);
+ bile_flush(db->bile, true);
db_cache_folders(db);
session_logf(s, "Created new folder %ld: %s", new_folder->id,
@@ -402,20 +404,19 @@ edit_folder:
folder->id, folder->name);
db_folder_delete(db, folder);
+ bile_flush(db->bile, true);
db_cache_folders(db);
break;
case 0:
- memcpy(&db->folders[n], new_folder, sizeof(struct folder));
-
ret = bile_marshall_object(db->bile, folder_object_fields,
- nfolder_object_fields, &db->folders[n], &data, &size);
+ nfolder_object_fields, new_folder, &data, &size);
if (ret != 0 || size == 0)
panic("folder: failed to marshall object");
if (bile_write(db->bile, DB_FOLDER_RTYPE, new_folder->id,
data, size) != size)
- panic("save of folder failed: %d",
- bile_error(db->bile));
+ panic("save of folder failed: %d", bile_error(db->bile));
+ bile_flush(db->bile, true);
xfree(&data);
session_logf(s, "Saved changes to folder %ld: %s",
@@ -516,6 +517,7 @@ motd_write:
}
bile_write(db->bile, DB_MOTD_RTYPE, new_id, motd,
strlen(motd) + 1);
+ bile_flush(db->bile, true);
session_printf(s, " saved!\r\n");
session_flush(s);