mirror of https://github.com/aria2/aria2
2009-07-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Make sure that stream is closed before renaming file. Unit test fails on mingw32 in the previous implementation. * src/CookieStorage.ccpull/1/head
parent
1731db1c60
commit
0d1d88257c
|
@ -1,3 +1,9 @@
|
|||
2009-07-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Make sure that stream is closed before renaming file. Unit test
|
||||
fails on mingw32 in the previous implementation.
|
||||
* src/CookieStorage.cc
|
||||
|
||||
2009-07-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed the unit test error without sqlite3
|
||||
|
|
|
@ -174,19 +174,28 @@ bool CookieStorage::load(const std::string& filename)
|
|||
bool CookieStorage::saveNsFormat(const std::string& filename)
|
||||
{
|
||||
std::string tempfilename = filename+"__temp";
|
||||
std::ofstream o(tempfilename.c_str(), std::ios::binary);
|
||||
if(!o) {
|
||||
_logger->error("Cannot create cookie file %s, cause %s",
|
||||
filename.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
for(std::deque<Cookie>::const_iterator i = _cookies.begin();
|
||||
i != _cookies.end(); ++i) {
|
||||
o << (*i).toNsCookieFormat() << "\n";
|
||||
{
|
||||
std::ofstream o(tempfilename.c_str(), std::ios::binary);
|
||||
if(!o) {
|
||||
_logger->error("Failed to save cookies to %s", filename.c_str());
|
||||
_logger->error("Cannot create cookie file %s, cause %s",
|
||||
filename.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
for(std::deque<Cookie>::const_iterator i = _cookies.begin();
|
||||
i != _cookies.end(); ++i) {
|
||||
o << (*i).toNsCookieFormat() << "\n";
|
||||
if(!o) {
|
||||
_logger->error("Failed to save cookies to %s, cause %s",
|
||||
filename.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
o.flush();
|
||||
if(!o) {
|
||||
_logger->error("Failed to save cookies to %s, cause %s",
|
||||
filename.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(File(tempfilename).renameTo(filename)) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue