--- lbbs/src/data_file_mgr.c 2025/11/07 13:56:11 1.1 +++ lbbs/src/data_file_mgr.c 2025/11/09 11:07:35 1.3 @@ -42,6 +42,8 @@ static const DATA_FILE_ITEM data_file_li {"活动看板", DATA_ACTIVE_BOARD}, {"浏览帮助", DATA_READ_HELP}, {"编辑帮助", DATA_EDITOR_HELP}, + {"敏感词表", CONF_BWF}, + {"穿梭配置", CONF_BBSNET}, }; static const int data_file_cnt = sizeof(data_file_list) / sizeof(DATA_FILE_ITEM); @@ -192,6 +194,11 @@ int data_file_mgr(void *param) break; } + if (SYS_server_exit) // Do not save data on shutdown + { + goto cleanup; + } + if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0) { log_error("open(%s) error (%d)\n", path, errno); @@ -210,19 +217,27 @@ int data_file_mgr(void *param) fd = -1; goto cleanup; } - fd = -1; - if (unlink(data_file_list[i].path) < 0) + // Make another copy of the data file so that the user editored copy will be kept after upgrade / reinstall + if ((fd = open(data_file_list[i].path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0) + { + log_error("open(%s) error (%d)\n", data_file_list[i].path, errno); + goto cleanup; + } + + if (write(fd, p_data_new, (size_t)len_data_new) < 0) { - log_error("unlink(%s) error (%d)\n", data_file_list[i].path, errno); + log_error("write(len=%ld) error (%d)\n", len_data_new, errno); goto cleanup; } - if (link(path, data_file_list[i].path) < 0) + if (close(fd) < 0) { - log_error("link(%s, %s) error (%d)\n", path, data_file_list[i].path, errno); + log_error("close(fd) error (%d)\n", errno); + fd = -1; goto cleanup; } + fd = -1; clearscr(); moveto(1, 1);