/[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.4 by sysadm, Tue Nov 11 00:28:05 2025 UTC
# Line 6  Line 6 
6   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7   */   */
8    
9    #ifdef HAVE_CONFIG_H
10    #include "config.h"
11    #endif
12    
13  #include "bbs.h"  #include "bbs.h"
14  #include "bbs_cmd.h"  #include "bbs_cmd.h"
15  #include "common.h"  #include "common.h"
# Line 42  static const DATA_FILE_ITEM data_file_li Line 46  static const DATA_FILE_ITEM data_file_li
46          {"活动看板", DATA_ACTIVE_BOARD},          {"活动看板", DATA_ACTIVE_BOARD},
47          {"浏览帮助", DATA_READ_HELP},          {"浏览帮助", DATA_READ_HELP},
48          {"编辑帮助", DATA_EDITOR_HELP},          {"编辑帮助", DATA_EDITOR_HELP},
49            {"敏感词表", CONF_BWF},
50            {"穿梭配置", CONF_BBSNET},
51  };  };
52    
53  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 198  int data_file_mgr(void *param)
198                  break;                  break;
199          }          }
200    
201            if (SYS_server_exit) // Do not save data on shutdown
202            {
203                    goto cleanup;
204            }
205    
206          if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0)          if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0)
207          {          {
208                  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 221  int data_file_mgr(void *param)
221                  fd = -1;                  fd = -1;
222                  goto cleanup;                  goto cleanup;
223          }          }
         fd = -1;  
224    
225          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
226            if ((fd = open(data_file_list[i].path, O_WRONLY | O_CREAT | O_TRUNC, 0640)) < 0)
227          {          {
228                  log_error("unlink(%s) error (%d)\n", data_file_list[i].path, errno);                  log_error("open(%s) error (%d)\n", data_file_list[i].path, errno);
229                  goto cleanup;                  goto cleanup;
230          }          }
231    
232          if (link(path, data_file_list[i].path) < 0)          if (write(fd, p_data_new, (size_t)len_data_new) < 0)
233          {          {
234                  log_error("link(%s, %s) error (%d)\n", path, data_file_list[i].path, errno);                  log_error("write(len=%ld) error (%d)\n", len_data_new, errno);
235                  goto cleanup;                  goto cleanup;
236          }          }
237    
238            if (close(fd) < 0)
239            {
240                    log_error("close(fd) error (%d)\n", errno);
241                    fd = -1;
242                    goto cleanup;
243            }
244            fd = -1;
245    
246          clearscr();          clearscr();
247          moveto(1, 1);          moveto(1, 1);
248          prints("修改已完成,需要重新加载配置后才会生效...");          prints("修改已完成,需要重新加载配置后才会生效...");


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

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