--- bm_srv12.c.070 2003-02-25 22:06:42.000000000 -0300 +++ bm_srv12.c 2003-02-25 22:45:28.000000000 -0300 @@ -851,7 +851,14 @@ int Bms_save() BmSec *sec_node; GSList *list, *list2; GString *gstr = g_string_new(""); - struct stat TimeStamp; + struct stat BmStat; + + /* make a safety backup */ + if (stat(BmFile, &BmStat) == 0 && BmStat.st_size > 256) { + gchar *BmFileBak = g_strconcat(BmFile, ".bak", NULL); + rename(BmFile, BmFileBak); + g_free(BmFileBak); + } /* open bm file */ if (!(BmTxt = fopen(BmFile, "w"))) { @@ -886,8 +893,8 @@ int Bms_save() fclose(BmTxt); /* keep track of the timestamp */ - stat(BmFile, &TimeStamp); - BmFileTimeStamp = TimeStamp.st_mtime; + stat(BmFile, &BmStat); + BmFileTimeStamp = BmStat.st_mtime; return 0; } @@ -1648,6 +1655,8 @@ int Bmsrv_parse_buf(int SockFD, char *Bu return 0; } + /* sync with the bookmarks file */ + Bms_cond_load(); if (cmd && strcmp(cmd, "add_bookmark") == 0) { g_free(cmd); @@ -1671,7 +1680,6 @@ int Bmsrv_parse_buf(int SockFD, char *Bu printf(" url=%s\n", url); if (strcmp(url, "dpi:/bm/modify") == 0) { - Bms_cond_load(); st = Bmsrv_send_modify_answer(SockFD, url); return st; @@ -1697,7 +1705,6 @@ int Bmsrv_parse_buf(int SockFD, char *Bu } printf(" sending page body...\n"); - Bms_cond_load(); st = send_bm_page(SockFD); if (st != 0) { char *err =