fixed: thread plugin didn't correctly set the last item and replies (in 'thread' table)

when deleting an answer
added: ThreadInfo::Repair() method
       will be used by 'fsck' winix function       
added: plugins/groupitem 
       directory for a new plugin: 'groupitem'
       


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@725 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2011-03-23 17:54:53 +00:00
parent ba63c8c661
commit d68731fd55
15 changed files with 498 additions and 50 deletions

View File

@ -25,10 +25,11 @@ winix: FORCE
@cd functions ; $(MAKE) -e
@cd templates ; $(MAKE) -e
@cd notify ; $(MAKE) -e
@cd plugins/stats ; $(MAKE) -e
@cd plugins/thread ; $(MAKE) -e
@cd plugins/ticket ; $(MAKE) -e
@cd plugins/gallery ; $(MAKE) -e
@cd plugins/stats ; $(MAKE) -e
@cd plugins/thread ; $(MAKE) -e
@cd plugins/ticket ; $(MAKE) -e
@cd plugins/gallery ; $(MAKE) -e
@cd plugins/groupitem ; $(MAKE) -e
@cd ../ezc/src ; $(MAKE) -e
$(CXX) -shared -o winix.so $(CXXFLAGS) core/*.o db/*.o functions/*.o templates/*.o notify/*.o ../ezc/src/ezc.a -lfcgi -lpq -lz -lpthread -lfetch
@cd main ; $(MAKE) -e
@ -43,10 +44,11 @@ clean:
@cd functions ; $(MAKE) -e clean
@cd templates ; $(MAKE) -e clean
@cd notify ; $(MAKE) -e clean
@cd plugins/stats ; $(MAKE) -e clean
@cd plugins/thread ; $(MAKE) -e clean
@cd plugins/ticket ; $(MAKE) -e clean
@cd plugins/gallery ; $(MAKE) -e clean
@cd plugins/stats ; $(MAKE) -e clean
@cd plugins/thread ; $(MAKE) -e clean
@cd plugins/ticket ; $(MAKE) -e clean
@cd plugins/gallery ; $(MAKE) -e clean
@cd plugins/groupitem ; $(MAKE) -e clean
@cd ../ezc/src ; $(MAKE) -e clean
@cd main ; $(MAKE) -e clean
rm -f winix.so
@ -62,10 +64,11 @@ depend:
@cd functions ; $(MAKE) -e depend
@cd templates ; $(MAKE) -e depend
@cd notify ; $(MAKE) -e depend
@cd plugins/stats ; $(MAKE) -e depend
@cd plugins/thread ; $(MAKE) -e depend
@cd plugins/ticket ; $(MAKE) -e depend
@cd plugins/gallery ; $(MAKE) -e depend
@cd plugins/stats ; $(MAKE) -e depend
@cd plugins/thread ; $(MAKE) -e depend
@cd plugins/ticket ; $(MAKE) -e depend
@cd plugins/gallery ; $(MAKE) -e depend
@cd plugins/groupitem ; $(MAKE) -e depend
@cd ../ezc/src ; $(MAKE) -e depend
@cd main ; $(MAKE) -e depend

View File

@ -14,6 +14,12 @@
DbItemQuery::DbItemQuery()
{
Clear();
}
void DbItemQuery::Clear()
{
sort_asc = true;
@ -30,6 +36,7 @@ DbItemQuery::DbItemQuery()
limit = 0; // limit and offset not used by default
offset = 0;
}

View File

@ -52,7 +52,8 @@ struct DbItemQuery
long offset;
DbItemQuery();
void Clear();
void SetAllSel(bool sel);
void SetAllWhere(bool where_);
void SetAll(bool sel, bool where_);

View File

@ -32,6 +32,7 @@
[if winix_function_is "ticket"]
[# !! dodac lightboxa tylko jesli tickety zawieraja obrazki ]
<link rel="stylesheet" href="[doc_base_url_common]/lightbox/lightbox.css" type="text/css" media="screen">
<script src="[doc_base_url_common]/lightbox/js/prototype.js" type="text/javascript"></script>
<script src="[doc_base_url_common]/lightbox/js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
@ -53,10 +54,5 @@
<script type="text/javascript" src="[doc_base_url_common]/jquery-1.4.2.min.js"></script>
<script src="[doc_base_url_common]/aino-galleria/src/galleria.js" type="text/javascript"></script>
[end]
[if gallery_mount_type_arg_is "galleriathumbwhite"]
<script type="text/javascript" src="[doc_base_url_common]/jquery-1.4.2.min.js"></script>
<script src="[doc_base_url_common]/aino-galleria-white/src/galleria.js" type="text/javascript"></script>
[end]
[end]

27
plugins/groupitem/Makefile Executable file
View File

@ -0,0 +1,27 @@
include Makefile.o.dep
name = groupitem.so
all: $(o)
$(CXX) -shared -Wl,-soname,$(name).so -o $(name) $(CXXFLAGS) *.o
.SUFFIXES: .cpp .o
.cpp.o:
$(CXX) -c $(CXXFLAGS) $<
depend:
makedepend -Y. -I../.. -I../../../ezc/src -f- *.cpp > Makefile.dep
echo -n "o = " > Makefile.o.dep
ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep
clean:
rm -f *.o
rm -f $(name)
include Makefile.dep

105
plugins/groupitem/Makefile.dep Executable file
View File

@ -0,0 +1,105 @@
# DO NOT DELETE
init.o: ../../core/log.h ../../core/textstream.h ../../core/misc.h
init.o: ../../core/item.h ../../core/plugin.h ../../core/pluginmsg.h
init.o: ../../core/log.h ../../core/plugindata.h ../../core/config.h
init.o: ../../core/confparser.h ../../core/htmlfilter.h ../../core/request.h
init.o: ../../core/requesttypes.h ../../core/error.h
init.o: ../../templates/htmltextstream.h ../../core/textstream.h
init.o: ../../core/system.h ../../core/dirs.h ../../core/dircontainer.h
init.o: ../../db/db.h ../../db/dbbase.h ../../db/dbconn.h
init.o: ../../db/dbtextstream.h ../../core/error.h ../../db/dbitemquery.h
init.o: ../../core/item.h ../../db/dbitemcolumns.h ../../core/user.h
init.o: ../../core/group.h ../../core/dircontainer.h ../../core/ugcontainer.h
init.o: ../../notify/notify.h ../../notify/notifypool.h
init.o: ../../templates/locale.h ../../core/confparser.h
init.o: ../../templates/misc.h ../../templates/localefilter.h
init.o: ../../templates/locale.h ../../../ezc/src/ezc.h
init.o: ../../../ezc/src/utf8.h ../../../ezc/src/generator.h
init.o: ../../../ezc/src/pattern.h ../../../ezc/src/functions.h
init.o: ../../../ezc/src/funinfo.h ../../../ezc/src/stringconv.h
init.o: ../../templates/htmltextstream.h ../../notify/notifythread.h
init.o: ../../core/basethread.h ../../core/synchro.h
init.o: ../../notify/templatesnotify.h ../../core/config.h ../../core/users.h
init.o: ../../core/user.h ../../core/ugcontainer.h ../../core/lastcontainer.h
init.o: ../../core/cur.h ../../core/session.h ../../core/rebus.h
init.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h
init.o: ../../core/users.h ../../core/groups.h ../../core/group.h
init.o: ../../core/loadavg.h ../../core/thumb.h ../../core/basethread.h
init.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
init.o: ../../functions/functions.h ../../functions/functionbase.h
init.o: ../../core/request.h ../../core/system.h ../../core/synchro.h
init.o: ../../functions/functionparser.h ../../core/cur.h
init.o: ../../functions/adduser.h ../../functions/cat.h
init.o: ../../functions/chmod.h ../../functions/privchanger.h
init.o: ../../functions/chown.h ../../functions/ckeditor.h
init.o: ../../functions/cp.h ../../functions/default.h
init.o: ../../functions/download.h ../../functions/emacs.h
init.o: ../../functions/last.h ../../functions/login.h
init.o: ../../functions/logout.h ../../functions/ln.h ../../functions/ls.h
init.o: ../../functions/mkdir.h ../../functions/mv.h ../../functions/node.h
init.o: ../../functions/priv.h ../../functions/reload.h ../../functions/rm.h
init.o: ../../functions/run.h ../../functions/specialdefault.h
init.o: ../../functions/stat.h ../../functions/subject.h
init.o: ../../functions/template.h ../../functions/tinymce.h
init.o: ../../functions/uname.h ../../functions/upload.h
init.o: ../../functions/uptime.h ../../functions/who.h ../../functions/vim.h
init.o: ../../core/htmlfilter.h ../../templates/templates.h
init.o: ../../templates/patterncacher.h ../../templates/ckeditorgetparser.h
init.o: ../../core/httpsimpleparser.h ../../core/log.h
init.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h
templates.o: ../../templates/templates.h ../../../ezc/src/ezc.h
templates.o: ../../../ezc/src/utf8.h ../../../ezc/src/generator.h
templates.o: ../../../ezc/src/pattern.h ../../core/item.h
templates.o: ../../../ezc/src/functions.h ../../../ezc/src/funinfo.h
templates.o: ../../../ezc/src/stringconv.h ../../core/misc.h
templates.o: ../../templates/patterncacher.h ../../core/item.h
templates.o: ../../templates/ckeditorgetparser.h
templates.o: ../../core/httpsimpleparser.h ../../core/log.h
templates.o: ../../templates/indexpatterns.h ../../templates/localefilter.h
templates.o: ../../templates/locale.h ../../core/config.h ../../db/db.h
templates.o: ../../db/dbbase.h ../../db/dbconn.h ../../db/dbtextstream.h
templates.o: ../../core/textstream.h ../../core/error.h
templates.o: ../../db/dbitemquery.h ../../db/dbitemcolumns.h
templates.o: ../../core/user.h ../../core/group.h ../../core/dircontainer.h
templates.o: ../../core/ugcontainer.h ../../core/log.h
templates.o: ../../templates/htmltextstream.h ../../core/cur.h
templates.o: ../../core/system.h ../../core/sessionmanager.h
templates.o: ../../core/plugin.h ../../core/pluginmsg.h
templates.o: ../../core/plugindata.h ../../core/config.h
templates.o: ../../core/confparser.h ../../core/htmlfilter.h
templates.o: ../../core/request.h ../../core/requesttypes.h
templates.o: ../../core/error.h ../../core/textstream.h
templates.o: ../../templates/htmltextstream.h ../../core/system.h
templates.o: ../../core/dirs.h ../../core/dircontainer.h
templates.o: ../../notify/notify.h ../../notify/notifypool.h
templates.o: ../../templates/locale.h ../../core/confparser.h
templates.o: ../../templates/misc.h ../../notify/notifythread.h
templates.o: ../../core/basethread.h ../../core/synchro.h
templates.o: ../../notify/templatesnotify.h ../../core/users.h
templates.o: ../../core/user.h ../../core/ugcontainer.h
templates.o: ../../core/lastcontainer.h ../../core/cur.h ../../core/session.h
templates.o: ../../core/rebus.h ../../core/mounts.h ../../core/mount.h
templates.o: ../../core/mountparser.h ../../core/users.h ../../core/groups.h
templates.o: ../../core/group.h ../../core/loadavg.h ../../core/thumb.h
templates.o: ../../core/basethread.h ../../core/sessionmanager.h
templates.o: ../../core/sessioncontainer.h ../../functions/functions.h
templates.o: ../../functions/functionbase.h ../../core/request.h
templates.o: ../../core/synchro.h ../../functions/functionparser.h
templates.o: ../../functions/adduser.h ../../functions/cat.h
templates.o: ../../functions/chmod.h ../../functions/privchanger.h
templates.o: ../../functions/chown.h ../../functions/ckeditor.h
templates.o: ../../functions/cp.h ../../functions/default.h
templates.o: ../../functions/download.h ../../functions/emacs.h
templates.o: ../../functions/last.h ../../functions/login.h
templates.o: ../../functions/logout.h ../../functions/ln.h
templates.o: ../../functions/ls.h ../../functions/mkdir.h
templates.o: ../../functions/mv.h ../../functions/node.h
templates.o: ../../functions/priv.h ../../functions/reload.h
templates.o: ../../functions/rm.h ../../functions/run.h
templates.o: ../../functions/specialdefault.h ../../functions/stat.h
templates.o: ../../functions/subject.h ../../functions/template.h
templates.o: ../../functions/tinymce.h ../../functions/uname.h
templates.o: ../../functions/upload.h ../../functions/uptime.h
templates.o: ../../functions/who.h ../../functions/vim.h
templates.o: ../../core/htmlfilter.h

View File

@ -0,0 +1 @@
o = init.o templates.o

50
plugins/groupitem/init.cpp Executable file
View File

@ -0,0 +1,50 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#include "core/log.h"
#include "core/plugin.h"
extern "C" void Init(PluginInfo &);
namespace Groupitem
{
const wchar_t plugin_name[] = L"groupitem";
void AddEzcFunctions(PluginInfo & info);
} // namespace
void Init(PluginInfo & info)
{
using namespace Groupitem;
plugin.Assign(WINIX_TEMPLATES_CREATEFUNCTIONS, AddEzcFunctions);
info.p1 = (void*)(plugin_name);
}

37
plugins/groupitem/templates.cpp Executable file
View File

@ -0,0 +1,37 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#include "templates/templates.h"
#include "core/plugin.h"
namespace Groupitem
{
using namespace TemplatesFunctions;
using TemplatesFunctions::system;
void AddEzcFunctions(PluginInfo & info)
{
using TemplatesFunctions::EzcFun;
EzcFun * fun = reinterpret_cast<EzcFun*>(info.p1);
// fun->Insert("gallery_tab", gallery_tab);
}
} // namespace

View File

@ -75,6 +75,7 @@ void AddMounts(PluginInfo & info)
void RemoveThread(PluginInfo & i)
{
thread_info.RemoveThread(i.l1);
thread_info.RemoveThreadAnswer(i.l1);
}
@ -128,6 +129,18 @@ void EndRequest(PluginInfo & info)
}
// !! temporarily
void Rescan(PluginInfo & info)
{
if( info.config->Bool(L"thread_rescan", false) == true )
{
log << log1 << "---------- rescanning thread db ------------- " << logend;
thread_info.Repair();
log << log1 << "---------- thread db rescanning is finished ------------- " << logend;
}
}
} // namespace
@ -152,6 +165,9 @@ using namespace Thread;
plugin.Assign(WINIX_PL_THREAD_SET_SORTTAB_INDEX, SetSortTabIndex);
plugin.Assign(WINIX_PL_THREAD_PREPARE_THREAD, PrepareThread);
// temporarily
plugin.Assign(WINIX_PLUGIN_INIT, Rescan);
tdb.SetConn(info.db->GetConn());
tdb.LogQueries(info.config->log_db_query);

View File

@ -75,7 +75,7 @@ void Reply::MakePost()
// !! jak bedzie dostepne assert
// ASSERT(files_dir)
if( tdb->GetThreadByFileId(cur->request->item.id, thread) != WINIX_ERR_OK )
if( tdb->GetThread(cur->request->item.id, thread) != WINIX_ERR_OK )
{
thread.Clear();
thread.file_id = cur->request->item.id;
@ -99,7 +99,7 @@ void Reply::MakePost()
cur->request->status = system->AddFile(answer);
if( cur->request->status == WINIX_ERR_OK )
cur->request->status = tdb->EditThreadAddItem(cur->request->item.id, answer.id);
cur->request->status = tdb->AddAnswer(cur->request->item.id, answer.id);
if( cur->request->status == WINIX_ERR_OK )

View File

@ -58,7 +58,7 @@ void TDb::SetThread(PGresult * r, int col, Thread & thread)
Error TDb::GetThreadByFileId(long file_id, Thread & thread)
Error TDb::GetThread(long file_id, Thread & thread)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
@ -175,7 +175,7 @@ return status;
Error TDb::EditThreadAddItem(long file_id, long answer_id)
Error TDb::AddAnswer(long file_id, long answer_id)
{
query.Clear();
query << R("insert into plugins.thread_files (file_id, answer_id) values (")
@ -200,7 +200,7 @@ return DoCommand(query);
long TDb::FindLastItem(long file_id)
long TDb::FindLastAnswer(long file_id)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
@ -231,7 +231,7 @@ return last_item_id;
Error TDb::EditThreadRemoveItem(long item_id)
Error TDb::RemoveAnswer(long answer_id)
{
PGresult * r1 = 0;
PGresult * r2 = 0;
@ -239,10 +239,10 @@ Error TDb::EditThreadRemoveItem(long item_id)
try
{
// selecting files which have item_id as an answer
// selecting files which have answer_id as an answer
query.Clear();
query << R("select file_id from plugins.thread_files where answer_id = ")
<< item_id
<< answer_id
<< R(";");
r1 = AssertQuery(query);
@ -254,10 +254,11 @@ Error TDb::EditThreadRemoveItem(long item_id)
for(int i=0 ; i<rows ; ++i)
file_id_tab[i] = AssertValueLong(r1, i, 0);
// deleting those answers
query.Clear();
query << R("delete from plugins.thread_files where answer_id = ")
<< item_id
<< answer_id
<< R(";");
r2 = AssertQuery(query);
@ -269,7 +270,7 @@ Error TDb::EditThreadRemoveItem(long item_id)
log << log2 << "ThreadDb: deleted " << rows << " rows from plugins.thread_files" << logend;
// setting new last_items to the files
status = EditThreadRecalcFiles(file_id_tab);
status = RemoveAnswerRecalcLast(file_id_tab);
}
catch(const Error & e)
{
@ -283,22 +284,28 @@ return status;
}
Error TDb::RemoveAnswerRecalcLast(long file_id)
{
long last_item_id = FindLastAnswer(file_id);
Error TDb::EditThreadRecalcFiles(const std::vector<long> & file_id_tab)
query.Clear();
query << R("update plugins.thread set (replies, last_item) = (replies-1,")
<< last_item_id
<< R(") where file_id=")
<< file_id
<< R(";");
return DoCommand(query);
}
Error TDb::RemoveAnswerRecalcLast(const std::vector<long> & file_id_tab)
{
for(size_t i=0 ; i<file_id_tab.size() ; ++i)
{
long file_id = file_id_tab[i];
long last_item_id = FindLastItem(file_id);
query.Clear();
query << R("update plugins.thread set (replies, last_item) = (replies-1,")
<< last_item_id
<< R(") where file_id=")
<< file_id
<< R(";");
Error status = DoCommand(query);
long file_id = file_id_tab[i];
Error status = RemoveAnswerRecalcLast(file_id);
if( status != WINIX_ERR_OK )
return status;
@ -308,6 +315,49 @@ return WINIX_ERR_OK;
}
Error TDb::RecalcThread(long file_id)
{
long replies = CalcAnswers(file_id);
long last_item = FindLastAnswer(file_id);
query.Clear();
query << R("update plugins.thread set (replies, last_item) = (")
<< replies
<< last_item
<< R(") where file_id=")
<< file_id
<< R(";");
return DoCommand(query);
}
long TDb::CalcAnswers(long file_id)
{
PGresult * r = 0;
long answers = 0;
try
{
query.Clear();
query << R("select count(file_id) from plugins.thread_files where file_id=") << file_id << R(";");
r = AssertQuery(query);
AssertResult(r, PGRES_TUPLES_OK);
if( Rows(r) == 1 )
answers = AssertValueLong(r, 0, 0);
}
catch(const Error &)
{
}
ClearResult(r);
return answers;
}
@ -354,6 +404,64 @@ return status;
Error TDb::RemoveAnswerOnly(long answer_id)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
try
{
query.Clear();
query << R("delete from plugins.thread_files where answer_id=") << answer_id << R(";");
r = AssertQuery(query);
AssertResult(r, PGRES_COMMAND_OK);
long rows = AffectedRows(r);
if( rows > 0 )
log << log2 << "ThreadDb: deleted " << rows << " rows from plugins.thread_files" << logend;
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}
void TDb::GetAllThreadsId(std::vector<long> & file_id)
{
PGresult * r = 0;
file_id.clear();
try
{
query.Clear();
query << R("select file_id from plugins.thread;");
r = AssertQuery(query);
AssertResult(r, PGRES_TUPLES_OK);
int rows = Rows(r);
file_id.resize(rows);
for(int i=0 ; i<rows ; ++i)
file_id[i] = AssertValueLong(r, i, 0);
}
catch(const Error &)
{
}
ClearResult(r);
}

View File

@ -26,14 +26,42 @@ class TDb : public DbBase
{
public:
/*
high level interface
*/
Error AddThread(const Thread & thread);
Error GetThreadByFileId(long file_id, Thread & thread);
Error GetThread(long file_id, Thread & thread);
Error GetThreads(const std::vector<long> & file_id_tab, std::vector<Thread> & thread_tab);
Error GetAnswers(long file_id, std::vector<long> & answer_id_tab);
Error EditThreadAddItem(long file_id, long answer_id);
Error EditThreadRemoveItem(long file_id);
Error RemoveThread(long file_id);
long FindLastItem(long file_id);
Error AddAnswer(long file_id, long answer_id);
Error GetAnswers(long file_id, std::vector<long> & answer_id_tab);
Error RemoveAnswer(long answer_id);
/*
low level interface
*/
// looking for the last answer in a thread (in 'thread_files' table)
// this is not the value from 'thread' table
long FindLastAnswer(long file_id);
// returning all threads id (file_id) (from 'thread' table)
void GetAllThreadsId(std::vector<long> & file_id);
// removing only the answer in 'thread_files' table without updating 'thread' table
Error RemoveAnswerOnly(long answer_id);
// returning how many answers there are
// calculating from 'thread_files' table
// this is not the value from 'thread' table
long CalcAnswers(long file_id);
// recalculating last_item, replies in 'thread' table on a given thread
Error RecalcThread(long file_id);
private:
@ -43,9 +71,10 @@ private:
Thread thread_temp;
std::vector<long> file_id_tab;
void SetThreadColumns(PGresult * r);
void SetThread(PGresult * r, int col, Thread & thread);
Error EditThreadRecalcFiles(const std::vector<long> & file_id_tab);
void SetThreadColumns(PGresult * r);
void SetThread(PGresult * r, int col, Thread & thread);
Error RemoveAnswerRecalcLast(long file_id);
Error RemoveAnswerRecalcLast(const std::vector<long> & file_id_tab);
};

View File

@ -71,6 +71,67 @@ void ThreadInfo::RemoveThread(long file_id)
void ThreadInfo::RemoveThreadAnswer(long answer_id)
{
tdb->RemoveAnswer(answer_id);
}
void ThreadInfo::RepairAnswer(long answer_id)
{
iq.Clear();
iq.SetAll(false, false);
iq.WhereId(answer_id);
iq.WhereType(Item::file); // !! moze w przyszlosci pozwolic takze na symlinki?
if( db->GetItem(repair_item, iq) == WINIX_ERR_NO_ITEM )
{
log << log3 << "ThreadInfo: there is no a file for thread answer_id: " << answer_id << logend;
tdb->RemoveAnswerOnly(answer_id);
}
}
void ThreadInfo::RepairAnswers(long file_id)
{
tdb->GetAnswers(file_id, repair_answer_tab);
for(size_t i=0 ; i<repair_answer_tab.size() ; ++i)
RepairAnswer(repair_answer_tab[i]);
}
void ThreadInfo::Repair(long file_id)
{
iq.Clear();
iq.SetAll(false, false);
iq.WhereId(file_id);
iq.WhereType(Item::file); // !! moze w przyszlosci pozwolic takze na symlinki?
if( db->GetItem(repair_item, iq) == WINIX_ERR_NO_ITEM )
{
log << log3 << "ThreadInfo: there is no a file for thread file_id: " << file_id << logend;
tdb->RemoveThread(file_id);
}
else
{
RepairAnswers(file_id);
tdb->RecalcThread(file_id);
}
}
void ThreadInfo::Repair()
{
tdb->GetAllThreadsId(repair_id_tab);
for(size_t i=0 ; i<repair_id_tab.size() ; ++i)
Repair(repair_id_tab[i]);
}
} // namespace

View File

@ -64,7 +64,10 @@ public:
void RemoveThread(long file_id);
void RemoveThreadAnswer(long answer_id);
// repairing the database
void Repair();
private:
@ -73,9 +76,13 @@ private:
System * system;
std::vector<Item*> out_dir_tab;
std::vector<long> remove_answer_id_tab;
Item out_item;
std::vector<long> remove_answer_id_tab, repair_id_tab, repair_answer_tab;
Item out_item, repair_item;
DbItemQuery iq;
void RepairAnswer(long answer_id);
void RepairAnswers(long file_id);
void Repair(long file_id);
};