diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-12-15 17:53:37 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-12-15 17:53:37 +0800 |
commit | 6cd1e2dd9904da07992c18b77f0586a4d77b61de (patch) | |
tree | f0262f726c6a3fba2f7fadaea15b9c31d34d6e0b | |
parent | c7179929b7a8a7e56abb07d57fd9e7936a2ca16e (diff) | |
download | pttbbs-6cd1e2dd9904da07992c18b77f0586a4d77b61de.tar pttbbs-6cd1e2dd9904da07992c18b77f0586a4d77b61de.tar.gz pttbbs-6cd1e2dd9904da07992c18b77f0586a4d77b61de.tar.bz2 pttbbs-6cd1e2dd9904da07992c18b77f0586a4d77b61de.tar.lz pttbbs-6cd1e2dd9904da07992c18b77f0586a4d77b61de.tar.xz pttbbs-6cd1e2dd9904da07992c18b77f0586a4d77b61de.tar.zst pttbbs-6cd1e2dd9904da07992c18b77f0586a4d77b61de.zip |
add SAFE_ARTICLE_DELETE,
when using 'd' to delete an article,
do not truncate .DIR immediately but add an empty record into the same place.
this avoids many problems.
(not complete yet)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1407 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/bbs.c | 13 | ||||
-rw-r--r-- | mbbsd/record.c | 13 | ||||
-rw-r--r-- | sample/pttbbs.conf | 5 |
3 files changed, 30 insertions, 1 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index a0385552..659e6544 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -947,6 +947,11 @@ edit_post(int ent, fileheader_t * fhdr, char *direct) if( currmode & MODE_SELECT ) return DONOTHING; +#ifdef SAFE_ARTICLE_DELETE + if( fhdr->filename[0] == '.' ) + return DONOTHING; +#endif + setutmpmode(REEDIT); setdirpath(genbuf, direct, fhdr->filename); local_article = fhdr->filemode & FILE_LOCAL; @@ -1833,7 +1838,13 @@ del_post(int ent, fileheader_t * fhdr, char *direct) getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO); if (genbuf[0] == 'y') { strlcpy(currfile, fhdr->filename, sizeof(currfile)); - if (!delete_file(direct, sizeof(fileheader_t), ent, cmpfilename)) { + if( +#ifdef SAFE_ARTICLE_DELETE + !safe_article_delete(ent, fhdr, direct) +#else + !delete_file(direct, sizeof(fileheader_t), ent, cmpfilename) +#endif + ) { int num; if (currmode & MODE_SELECT) { /* rocker.011018: 利用reference減低loading */ diff --git a/mbbsd/record.c b/mbbsd/record.c index e4c2897f..c28a0c6d 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -400,6 +400,19 @@ int delete_files(char *dirname, int (*filecheck) (), int record){ return ans; } +#ifdef SAFE_ARTICLE_DELETE +int +safe_article_delete(int ent, fileheader_t *fhdr, char *direct) +{ + fileheader_t newfhdr; + memcpy(&newfhdr, fhdr, sizeof(fileheader_t)); + sprintf(newfhdr.title, "(本文已被刪除)"); + strcpy(newfhdr.filename, ".deleted"); + substitute_record(direct, &newfhdr, sizeof(newfhdr), ent); + return 0; +} +#endif + int delete_file(char *dirname, int size, int ent, int (*filecheck) ()) { diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf index ff006f90..25e2b250 100644 --- a/sample/pttbbs.conf +++ b/sample/pttbbs.conf @@ -119,6 +119,11 @@ /* 使用 rfork()取代 fork() . 目前只在 FreeBSD上有效 */ //#define USE_RFORK +/* 若定義, 則在刪除看板文章的時候, 僅會在 .DIR 中標明, 並不會將該資料 + 從 .DIR 中拿掉. 可以避免多項問題 (尤其是熱門看板一堆推薦及編輯時) + 須配合使用 (尚未完成) */ +//#define SAFE_ARTICLE_DELETE + /* 前進站畫面 */ #define INSCREEN \ "前進站畫面 (請至 pttbbs.conf 修改您的前進站畫面)" |