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

Diff of /lbbs/src/section_list_loader.c

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

Revision 1.10 by sysadm, Thu May 29 02:21:31 2025 UTC Revision 1.12 by sysadm, Fri May 30 12:51:00 2025 UTC
# Line 15  Line 15 
15   ***************************************************************************/   ***************************************************************************/
16    
17  #include "section_list_loader.h"  #include "section_list_loader.h"
18    #include "article_cache.h"
19  #include "log.h"  #include "log.h"
20  #include "database.h"  #include "database.h"
21  #include "menu.h"  #include "menu.h"
# Line 180  int append_articles_from_db(int32_t star Line 181  int append_articles_from_db(int32_t star
181          }          }
182    
183          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
184                           "SELECT AID, TID, SID, CID, UID, visible, excerption, ontop, `lock`, "                           "SELECT bbs.AID, TID, SID, bbs.CID, UID, visible, excerption, ontop, `lock`, "
185                           "transship, username, nickname, title, UNIX_TIMESTAMP(sub_dt) AS sub_dt "                           "transship, username, nickname, title, UNIX_TIMESTAMP(sub_dt) AS sub_dt, "
186                           "FROM bbs WHERE AID >= %d ORDER BY AID LIMIT %d",                           "bbs_content.content "
187                             "FROM bbs INNER JOIN bbs_content ON bbs.CID = bbs_content.CID "
188                             "WHERE bbs.AID >= %d ORDER BY bbs.AID LIMIT %d",
189                           start_aid, article_count_limit);                           start_aid, article_count_limit);
190    
191          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
# Line 190  int append_articles_from_db(int32_t star Line 193  int append_articles_from_db(int32_t star
193                  log_error("Query article list error: %s\n", mysql_error(db));                  log_error("Query article list error: %s\n", mysql_error(db));
194                  return -3;                  return -3;
195          }          }
196          if ((rs = mysql_store_result(db)) == NULL)          if ((rs = mysql_use_result(db)) == NULL)
197          {          {
198                  log_error("Get article list data failed\n");                  log_error("Get article list data failed\n");
199                  return -3;                  return -3;
# Line 238  int append_articles_from_db(int32_t star Line 241  int append_articles_from_db(int32_t star
241                  {                  {
242                          if ((ret = section_list_rw_unlock(p_section)) < 0)                          if ((ret = section_list_rw_unlock(p_section)) < 0)
243                          {                          {
244                                  log_error("section_list_rw_unlock(sid = %d) error\n", p_section->sid);                                  log_error("section_list_rw_unlock(sid=%d) error\n", p_section->sid);
245                                  break;                                  break;
246                          }                          }
247                  }                  }
# Line 267  int append_articles_from_db(int32_t star Line 270  int append_articles_from_db(int32_t star
270                  {                  {
271                          if ((ret = section_list_rw_lock(p_section)) < 0)                          if ((ret = section_list_rw_lock(p_section)) < 0)
272                          {                          {
273                                  log_error("section_list_rw_lock(sid = 0) error\n");                                  log_error("section_list_rw_lock(sid=0) error\n");
274                                  break;                                  break;
275                          }                          }
276                  }                  }
# Line 277  int append_articles_from_db(int32_t star Line 280  int append_articles_from_db(int32_t star
280    
281                  if (section_list_append_article(p_section, &article) < 0)                  if (section_list_append_article(p_section, &article) < 0)
282                  {                  {
283                          log_error("section_list_append_article(sid = %d, aid = %d) error\n",                          log_error("section_list_append_article(sid=%d, aid=%d) error\n",
284                                            p_section->sid, article.aid);                                            p_section->sid, article.aid);
285                          ret = -3;                          ret = -3;
286                          break;                          break;
# Line 285  int append_articles_from_db(int32_t star Line 288  int append_articles_from_db(int32_t star
288    
289                  article_count++;                  article_count++;
290    
291                  // TODO: generate content cache                  if (article_cache_generate(VAR_ARTICLE_CACHE_DIR, &article, row[i++], 0) < 0)
292                    {
293                            log_error("article_cache_generate(aid=%d, cid=%d) error\n", article.aid, article.cid);
294                            ret = -4;
295                            break;
296                    }
297          }          }
298    
299          // release lock of last section          // release lock of last section
# Line 293  int append_articles_from_db(int32_t star Line 301  int append_articles_from_db(int32_t star
301          {          {
302                  if ((ret = section_list_rw_unlock(p_section)) < 0)                  if ((ret = section_list_rw_unlock(p_section)) < 0)
303                  {                  {
304                          log_error("section_list_rw_unlock(sid = %d) error\n", p_section->sid);                          log_error("section_list_rw_unlock(sid=%d) error\n", p_section->sid);
305                  }                  }
306          }          }
307    
# Line 302  int append_articles_from_db(int32_t star Line 310  int append_articles_from_db(int32_t star
310          {          {
311                  if ((ret = section_list_rw_unlock(NULL)) < 0)                  if ((ret = section_list_rw_unlock(NULL)) < 0)
312                  {                  {
313                          log_error("section_list_rw_unlock(sid = 0) error\n");                          log_error("section_list_rw_unlock(sid=0) error\n");
314                  }                  }
315          }          }
316    
# Line 459  int apply_article_op_log_from_db(int op_ Line 467  int apply_article_op_log_from_db(int op_
467                          break;                          break;
468                  case 'M': // Modify article                  case 'M': // Modify article
469                          snprintf(sql, sizeof(sql),                          snprintf(sql, sizeof(sql),
470                                           "SELECT CID FROM bbs WHERE AID = %d",                                           "SELECT bbs.CID, bbs_content.content "
471                                             "FROM bbs INNER JOIN bbs_content ON bbs.CID = bbs_content.CID "
472                                             "WHERE bbs.AID = %d",
473                                           p_article->aid);                                           p_article->aid);
474    
475                          if (mysql_query(db, sql) != 0)                          if (mysql_query(db, sql) != 0)
# Line 468  int apply_article_op_log_from_db(int op_ Line 478  int apply_article_op_log_from_db(int op_
478                                  ret = -3;                                  ret = -3;
479                                  break;                                  break;
480                          }                          }
481                          if ((rs2 = mysql_store_result(db)) == NULL)                          if ((rs2 = mysql_use_result(db)) == NULL)
482                          {                          {
483                                  log_error("Get article data failed\n");                                  log_error("Get article data failed\n");
484                                  ret = -3;                                  ret = -3;
# Line 477  int apply_article_op_log_from_db(int op_ Line 487  int apply_article_op_log_from_db(int op_
487                          if ((row2 = mysql_fetch_row(rs2)))                          if ((row2 = mysql_fetch_row(rs2)))
488                          {                          {
489                                  p_article->cid = atoi(row2[0]);                                  p_article->cid = atoi(row2[0]);
490    
491                                    if (article_cache_generate(VAR_ARTICLE_CACHE_DIR, p_article, row2[1], 0) < 0)
492                                    {
493                                            log_error("article_cache_generate(aid=%d, cid=%d) error\n", p_article->aid, p_article->cid);
494                                            ret = -4;
495                                    }
496                          }                          }
497                          else                          else
498                          {                          {
# Line 484  int apply_article_op_log_from_db(int op_ Line 500  int apply_article_op_log_from_db(int op_
500                                  ret = -4;                                  ret = -4;
501                          }                          }
502                          mysql_free_result(rs2);                          mysql_free_result(rs2);
   
                         if (p_article->cid > 0)  
                         {  
                                 // TODO: generate content cache  
                         }  
   
503                          break;                          break;
504                  case 'T': // Move article                  case 'T': // Move article
505                          snprintf(sql, sizeof(sql),                          snprintf(sql, sizeof(sql),


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

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