/[LeafOK_CVS]/lbbs/src/data_file_mgr.c
ViewVC logotype

Diff of /lbbs/src/data_file_mgr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 by sysadm, Fri Nov 7 13:56:11 2025 UTC Revision 1.3 by sysadm, Sun Nov 9 11:07:35 2025 UTC
# Line 42  static const DATA_FILE_ITEM data_file_li Line 42  static const DATA_FILE_ITEM data_file_li
42          {"活动看板", DATA_ACTIVE_BOARD},          {"活动看板", DATA_ACTIVE_BOARD},
43          {"浏览帮助", DATA_READ_HELP},          {"浏览帮助", DATA_READ_HELP},
44          {"编辑帮助", DATA_EDITOR_HELP},          {"编辑帮助", DATA_EDITOR_HELP},
45            {"敏感词表", CONF_BWF},
46            {"穿梭配置", CONF_BBSNET},
47  };  };
48    
49  static const int data_file_cnt = sizeof(data_file_list) / sizeof(DATA_FILE_ITEM);  static const int data_file_cnt = sizeof(data_file_list) / sizeof(DATA_FILE_ITEM);
# Line 192  int data_file_mgr(void *param) Line 194  int data_file_mgr(void *param)
194                  break;                  break;
195          }          }
196    
197            if (SYS_server_exit) // Do not save data on shutdown
198            {
199                    goto cleanup;
200            }
201    
202          if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0)          if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0)
203          {          {
204                  log_error("open(%s) error (%d)\n", path, errno);                  log_error("open(%s) error (%d)\n", path, errno);
# Line 210  int data_file_mgr(void *param) Line 217  int data_file_mgr(void *param)
217                  fd = -1;                  fd = -1;
218                  goto cleanup;                  goto cleanup;
219          }          }
         fd = -1;  
220    
221          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
222            if ((fd = open(data_file_list[i].path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0)
223            {
224                    log_error("open(%s) error (%d)\n", data_file_list[i].path, errno);
225                    goto cleanup;
226            }
227    
228            if (write(fd, p_data_new, (size_t)len_data_new) < 0)
229          {          {
230                  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);
231                  goto cleanup;                  goto cleanup;
232          }          }
233    
234          if (link(path, data_file_list[i].path) < 0)          if (close(fd) < 0)
235          {          {
236                  log_error("link(%s, %s) error (%d)\n", path, data_file_list[i].path, errno);                  log_error("close(fd) error (%d)\n", errno);
237                    fd = -1;
238                  goto cleanup;                  goto cleanup;
239          }          }
240            fd = -1;
241    
242          clearscr();          clearscr();
243          moveto(1, 1);          moveto(1, 1);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1