-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command to forcibly write all in-memory data to the DB
- Loading branch information
1 parent
2a2ef8c
commit e02414e
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include "module.h" | ||
|
||
class CommandOSSave : public Command | ||
{ | ||
public: | ||
CommandOSSave(Module *creator) : Command(creator, "operserv/save", 0, 0) | ||
{ | ||
this->SetDesc(_("Write all objects to the database.")); | ||
} | ||
|
||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override | ||
{ | ||
Log(LOG_ADMIN, source, this); | ||
source.Reply(_("Writing objects.")); | ||
const std::list<Serializable *> &items = Serializable::GetItems(); | ||
for (std::list<Serializable *>::const_iterator it = items.begin(), it_end = items.end(); it != it_end; it++) | ||
{ | ||
(*it)->QueueUpdate(); | ||
} | ||
|
||
source.Reply(_("%d writes queued."), items.size()); | ||
return; | ||
} | ||
|
||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override | ||
{ | ||
this->SendSyntax(source); | ||
source.Reply(" "); | ||
source.Reply(_("Forces all changes to be written immediately.")); | ||
return true; | ||
} | ||
}; | ||
|
||
class OSSave : public Module | ||
{ | ||
CommandOSSave commandossave; | ||
|
||
public: | ||
OSSave(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, THIRD), | ||
commandossave(this) | ||
{ | ||
} | ||
}; | ||
|
||
MODULE_INIT(OSSave) |