mirror of https://github.com/aria2/aria2
2008-08-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Externalized message. * src/RequestGroupMan.cc * src/message.hpull/1/head
parent
ef2478b246
commit
33ad8505cd
|
@ -1,3 +1,9 @@
|
|||
2008-08-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Externalized message.
|
||||
* src/RequestGroupMan.cc
|
||||
* src/message.h
|
||||
|
||||
2008-08-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Save temporary file first and rename to the destination on success.
|
||||
|
|
|
@ -483,16 +483,14 @@ bool RequestGroupMan::loadServerStat(const std::string& filename)
|
|||
{
|
||||
std::ifstream in(filename.c_str());
|
||||
if(!in) {
|
||||
_logger->error("Failed to open ServerStat file %s for read.",
|
||||
filename.c_str());
|
||||
_logger->error(MSG_OPENING_READABLE_SERVER_STAT_FILE_FAILED, filename.c_str());
|
||||
return false;
|
||||
}
|
||||
if(_serverStatMan->load(in)) {
|
||||
_logger->notice("ServerStat file %s loaded successfully.",
|
||||
filename.c_str());
|
||||
_logger->notice(MSG_SERVER_STAT_LOADED, filename.c_str());
|
||||
return true;
|
||||
} else {
|
||||
_logger->error("Failed to read ServerStat from %s.", filename.c_str());
|
||||
_logger->error(MSG_READING_SERVER_STAT_FILE_FAILED, filename.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -502,15 +500,15 @@ bool RequestGroupMan::saveServerStat(const std::string& filename) const
|
|||
std::string tempfile = filename+"__temp";
|
||||
std::ofstream out(tempfile.c_str());
|
||||
if(!out) {
|
||||
_logger->error("Failed to open ServerStat file %s for write.",
|
||||
_logger->error(MSG_OPENING_WRITABLE_SERVER_STAT_FILE_FAILED,
|
||||
tempfile.c_str());
|
||||
return false;
|
||||
}
|
||||
if(_serverStatMan->save(out) && File(tempfile).renameTo(filename)) {
|
||||
_logger->notice("ServerStat file %s saved successfully.", filename.c_str());
|
||||
_logger->notice(MSG_SERVER_STAT_SAVED, filename.c_str());
|
||||
return true;
|
||||
} else {
|
||||
_logger->error("Failed to write ServerStat to %s.", filename.c_str());
|
||||
_logger->error(MSG_WRITING_SERVER_STAT_FILE_FAILED, filename.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,16 @@
|
|||
" doesn't verify signatures.")
|
||||
#define MSG_SIGNATURE_NOT_SAVED _("Saving signature as %s failed. Maybe file"\
|
||||
" already exists.")
|
||||
#define MSG_OPENING_READABLE_SERVER_STAT_FILE_FAILED \
|
||||
_("Failed to open ServerStat file %s for read.")
|
||||
#define MSG_SERVER_STAT_LOADED _("ServerStat file %s loaded successfully.")
|
||||
#define MSG_READING_SERVER_STAT_FILE_FAILED _("Failed to read ServerStat from" \
|
||||
" %s.")
|
||||
#define MSG_OPENING_WRITABLE_SERVER_STAT_FILE_FAILED \
|
||||
_("Failed to open ServerStat file %s for write.")
|
||||
#define MSG_SERVER_STAT_SAVED _("ServerStat file %s saved successfully.")
|
||||
#define MSG_WRITING_SERVER_STAT_FILE_FAILED _("Failed to write ServerStat to"\
|
||||
" %s.")
|
||||
|
||||
#define EX_TIME_OUT _("Timeout.")
|
||||
#define EX_INVALID_CHUNK_SIZE _("Invalid chunk size.")
|
||||
|
|
Loading…
Reference in New Issue