mirror of https://github.com/aria2/aria2
Removed utf8ToNative from log message and exception message.
parent
7368c9c9d8
commit
02307cee0a
|
@ -103,7 +103,7 @@ void AbstractDiskWriter::openExistingFile(uint64_t totalLength)
|
||||||
throw DL_ABORT_EX3
|
throw DL_ABORT_EX3
|
||||||
(errNum,
|
(errNum,
|
||||||
fmt(EX_FILE_OPEN,
|
fmt(EX_FILE_OPEN,
|
||||||
utf8ToNative(filename_).c_str(),
|
filename_.c_str(),
|
||||||
util::safeStrerror(errNum).c_str()),
|
util::safeStrerror(errNum).c_str()),
|
||||||
error_code::FILE_OPEN_ERROR);
|
error_code::FILE_OPEN_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ void AbstractDiskWriter::createFile(int addFlags)
|
||||||
throw DL_ABORT_EX3
|
throw DL_ABORT_EX3
|
||||||
(errNum,
|
(errNum,
|
||||||
fmt(EX_FILE_OPEN,
|
fmt(EX_FILE_OPEN,
|
||||||
utf8ToNative(filename_).c_str(),
|
filename_.c_str(),
|
||||||
util::safeStrerror(errNum).c_str()),
|
util::safeStrerror(errNum).c_str()),
|
||||||
error_code::FILE_CREATE_ERROR);
|
error_code::FILE_CREATE_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ void AbstractDiskWriter::seek(off_t offset)
|
||||||
if(a2lseek(fd_, offset, SEEK_SET) == (off_t)-1) {
|
if(a2lseek(fd_, offset, SEEK_SET) == (off_t)-1) {
|
||||||
int errNum = errno;
|
int errNum = errno;
|
||||||
throw DL_ABORT_EX2(fmt(EX_FILE_SEEK,
|
throw DL_ABORT_EX2(fmt(EX_FILE_SEEK,
|
||||||
utf8ToNative(filename_).c_str(),
|
filename_.c_str(),
|
||||||
util::safeStrerror(errNum).c_str()),
|
util::safeStrerror(errNum).c_str()),
|
||||||
error_code::FILE_IO_ERROR);
|
error_code::FILE_IO_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -171,14 +171,14 @@ void AbstractDiskWriter::writeData(const unsigned char* data, size_t len, off_t
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION3
|
throw DOWNLOAD_FAILURE_EXCEPTION3
|
||||||
(errNum,
|
(errNum,
|
||||||
fmt(EX_FILE_WRITE,
|
fmt(EX_FILE_WRITE,
|
||||||
utf8ToNative(filename_).c_str(),
|
filename_.c_str(),
|
||||||
util::safeStrerror(errNum).c_str()),
|
util::safeStrerror(errNum).c_str()),
|
||||||
error_code::NOT_ENOUGH_DISK_SPACE);
|
error_code::NOT_ENOUGH_DISK_SPACE);
|
||||||
} else {
|
} else {
|
||||||
throw DL_ABORT_EX3
|
throw DL_ABORT_EX3
|
||||||
(errNum,
|
(errNum,
|
||||||
fmt(EX_FILE_WRITE,
|
fmt(EX_FILE_WRITE,
|
||||||
utf8ToNative(filename_).c_str(),
|
filename_.c_str(),
|
||||||
util::safeStrerror(errNum).c_str()),
|
util::safeStrerror(errNum).c_str()),
|
||||||
error_code::FILE_IO_ERROR);
|
error_code::FILE_IO_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ ssize_t AbstractDiskWriter::readData(unsigned char* data, size_t len, off_t offs
|
||||||
throw DL_ABORT_EX3
|
throw DL_ABORT_EX3
|
||||||
(errNum,
|
(errNum,
|
||||||
fmt(EX_FILE_READ,
|
fmt(EX_FILE_READ,
|
||||||
utf8ToNative(filename_).c_str(),
|
filename_.c_str(),
|
||||||
util::safeStrerror(errNum).c_str()),
|
util::safeStrerror(errNum).c_str()),
|
||||||
error_code::FILE_IO_ERROR);
|
error_code::FILE_IO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ bool BtDependency::resolve()
|
||||||
if(d == ctxFilesEnd) {
|
if(d == ctxFilesEnd) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(fmt("No entry %s in torrent file",
|
(fmt("No entry %s in torrent file",
|
||||||
utf8ToNative((*s)->getOriginalName()).c_str()));
|
(*s)->getOriginalName().c_str()));
|
||||||
}
|
}
|
||||||
copyValues(*d, *s);
|
copyValues(*d, *s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ void BtPostDownloadHandler::getNextRequestGroups
|
||||||
RequestGroup* requestGroup)
|
RequestGroup* requestGroup)
|
||||||
{
|
{
|
||||||
A2_LOG_INFO(fmt("Generating RequestGroups for Torrent file %s",
|
A2_LOG_INFO(fmt("Generating RequestGroups for Torrent file %s",
|
||||||
utf8ToNative(requestGroup->getFirstFilePath()).c_str()));
|
requestGroup->getFirstFilePath().c_str()));
|
||||||
std::string content;
|
std::string content;
|
||||||
try {
|
try {
|
||||||
requestGroup->getPieceStorage()->getDiskAdaptor()->openExistingFile();
|
requestGroup->getPieceStorage()->getDiskAdaptor()->openExistingFile();
|
||||||
|
|
|
@ -73,8 +73,7 @@ bool CheckIntegrityCommand::executeInternal()
|
||||||
if(getRequestGroup()->downloadFinished()) {
|
if(getRequestGroup()->downloadFinished()) {
|
||||||
A2_LOG_NOTICE
|
A2_LOG_NOTICE
|
||||||
(fmt(MSG_VERIFICATION_SUCCESSFUL,
|
(fmt(MSG_VERIFICATION_SUCCESSFUL,
|
||||||
utf8ToNative(getRequestGroup()->getDownloadContext()
|
getRequestGroup()->getDownloadContext()->getBasePath().c_str()));
|
||||||
->getBasePath()).c_str()));
|
|
||||||
std::vector<Command*>* commands = new std::vector<Command*>();
|
std::vector<Command*>* commands = new std::vector<Command*>();
|
||||||
auto_delete_container<std::vector<Command*> > commandsDel(commands);
|
auto_delete_container<std::vector<Command*> > commandsDel(commands);
|
||||||
entry_->onDownloadFinished(*commands, getDownloadEngine());
|
entry_->onDownloadFinished(*commands, getDownloadEngine());
|
||||||
|
@ -83,8 +82,7 @@ bool CheckIntegrityCommand::executeInternal()
|
||||||
} else {
|
} else {
|
||||||
A2_LOG_ERROR
|
A2_LOG_ERROR
|
||||||
(fmt(MSG_VERIFICATION_FAILED,
|
(fmt(MSG_VERIFICATION_FAILED,
|
||||||
utf8ToNative(getRequestGroup()->getDownloadContext()
|
getRequestGroup()->getDownloadContext()->getBasePath().c_str()));
|
||||||
->getBasePath()).c_str()));
|
|
||||||
std::vector<Command*>* commands = new std::vector<Command*>();
|
std::vector<Command*>* commands = new std::vector<Command*>();
|
||||||
auto_delete_container<std::vector<Command*> > commandsDel(commands);
|
auto_delete_container<std::vector<Command*> > commandsDel(commands);
|
||||||
entry_->onDownloadIncomplete(*commands, getDownloadEngine());
|
entry_->onDownloadIncomplete(*commands, getDownloadEngine());
|
||||||
|
@ -108,8 +106,7 @@ bool CheckIntegrityCommand::handleException(Exception& e)
|
||||||
A2_LOG_ERROR
|
A2_LOG_ERROR
|
||||||
(fmt(MSG_DOWNLOAD_NOT_COMPLETE,
|
(fmt(MSG_DOWNLOAD_NOT_COMPLETE,
|
||||||
getCuid(),
|
getCuid(),
|
||||||
utf8ToNative(getRequestGroup()->getDownloadContext()
|
getRequestGroup()->getDownloadContext()->getBasePath().c_str()));
|
||||||
->getBasePath()).c_str()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -341,8 +341,7 @@ bool CookieStorage::load(const std::string& filename, time_t now)
|
||||||
{
|
{
|
||||||
BufferedFile fp(filename, BufferedFile::READ);
|
BufferedFile fp(filename, BufferedFile::READ);
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
A2_LOG_ERROR(fmt("Failed to open cookie file %s",
|
A2_LOG_ERROR(fmt("Failed to open cookie file %s", filename.c_str()));
|
||||||
utf8ToNative(filename).c_str()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
headlen = fp.read(header, sizeof(header));
|
headlen = fp.read(header, sizeof(header));
|
||||||
|
@ -372,8 +371,7 @@ bool CookieStorage::load(const std::string& filename, time_t now)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch(RecoverableException& e) {
|
} catch(RecoverableException& e) {
|
||||||
A2_LOG_ERROR(fmt("Failed to load cookies from %s",
|
A2_LOG_ERROR(fmt("Failed to load cookies from %s", filename.c_str()));
|
||||||
utf8ToNative(filename).c_str()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,21 +382,18 @@ bool CookieStorage::saveNsFormat(const std::string& filename)
|
||||||
{
|
{
|
||||||
BufferedFile fp(tempfilename, BufferedFile::WRITE);
|
BufferedFile fp(tempfilename, BufferedFile::WRITE);
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
A2_LOG_ERROR(fmt("Cannot create cookie file %s",
|
A2_LOG_ERROR(fmt("Cannot create cookie file %s", filename.c_str()));
|
||||||
utf8ToNative(filename).c_str()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(std::deque<DomainEntry>::const_iterator i = domains_.begin(),
|
for(std::deque<DomainEntry>::const_iterator i = domains_.begin(),
|
||||||
eoi = domains_.end(); i != eoi; ++i) {
|
eoi = domains_.end(); i != eoi; ++i) {
|
||||||
if(!(*i).writeCookie(fp)) {
|
if(!(*i).writeCookie(fp)) {
|
||||||
A2_LOG_ERROR(fmt("Failed to save cookies to %s",
|
A2_LOG_ERROR(fmt("Failed to save cookies to %s", filename.c_str()));
|
||||||
utf8ToNative(filename).c_str()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(fp.close() == EOF) {
|
if(fp.close() == EOF) {
|
||||||
A2_LOG_ERROR(fmt("Failed to save cookies to %s",
|
A2_LOG_ERROR(fmt("Failed to save cookies to %s", filename.c_str()));
|
||||||
utf8ToNative(filename).c_str()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,8 +401,8 @@ bool CookieStorage::saveNsFormat(const std::string& filename)
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
A2_LOG_ERROR(fmt("Could not rename file %s as %s",
|
A2_LOG_ERROR(fmt("Could not rename file %s as %s",
|
||||||
utf8ToNative(tempfilename).c_str(),
|
tempfilename.c_str(),
|
||||||
utf8ToNative(filename).c_str()));
|
filename.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,11 +76,11 @@ void readBytes(BufferedFile& fp,
|
||||||
void DHTRoutingTableDeserializer::deserialize(const std::string& filename)
|
void DHTRoutingTableDeserializer::deserialize(const std::string& filename)
|
||||||
{
|
{
|
||||||
A2_LOG_INFO(fmt("Loading DHT routing table from %s.",
|
A2_LOG_INFO(fmt("Loading DHT routing table from %s.",
|
||||||
utf8ToNative(filename).c_str()));
|
filename.c_str()));
|
||||||
BufferedFile fp(filename, BufferedFile::READ);
|
BufferedFile fp(filename, BufferedFile::READ);
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
throw DL_ABORT_EX(fmt("Failed to load DHT routing table from %s",
|
throw DL_ABORT_EX(fmt("Failed to load DHT routing table from %s",
|
||||||
utf8ToNative(filename).c_str()));
|
filename.c_str()));
|
||||||
}
|
}
|
||||||
char header[8];
|
char header[8];
|
||||||
memset(header, 0, sizeof(header));
|
memset(header, 0, sizeof(header));
|
||||||
|
@ -122,7 +122,7 @@ void DHTRoutingTableDeserializer::deserialize(const std::string& filename)
|
||||||
} else {
|
} else {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(fmt("Failed to load DHT routing table from %s. cause:%s",
|
(fmt("Failed to load DHT routing table from %s. cause:%s",
|
||||||
utf8ToNative(filename).c_str(),
|
filename.c_str(),
|
||||||
"bad header"));
|
"bad header"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,18 +72,17 @@ void DHTRoutingTableSerializer::setNodes
|
||||||
#define WRITE_CHECK(fp, ptr, count) \
|
#define WRITE_CHECK(fp, ptr, count) \
|
||||||
if(fp.write((ptr), (count)) != (count)) { \
|
if(fp.write((ptr), (count)) != (count)) { \
|
||||||
throw DL_ABORT_EX(fmt("Failed to save DHT routing table to %s.", \
|
throw DL_ABORT_EX(fmt("Failed to save DHT routing table to %s.", \
|
||||||
utf8ToNative(filename).c_str())); \
|
filename.c_str())); \
|
||||||
}
|
}
|
||||||
|
|
||||||
void DHTRoutingTableSerializer::serialize(const std::string& filename)
|
void DHTRoutingTableSerializer::serialize(const std::string& filename)
|
||||||
{
|
{
|
||||||
A2_LOG_INFO(fmt("Saving DHT routing table to %s.",
|
A2_LOG_INFO(fmt("Saving DHT routing table to %s.", filename.c_str()));
|
||||||
utf8ToNative(filename).c_str()));
|
|
||||||
std::string filenameTemp = filename+"__temp";
|
std::string filenameTemp = filename+"__temp";
|
||||||
BufferedFile fp(filenameTemp, BufferedFile::WRITE);
|
BufferedFile fp(filenameTemp, BufferedFile::WRITE);
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
throw DL_ABORT_EX(fmt("Failed to save DHT routing table to %s.",
|
throw DL_ABORT_EX(fmt("Failed to save DHT routing table to %s.",
|
||||||
utf8ToNative(filename).c_str()));
|
filename.c_str()));
|
||||||
}
|
}
|
||||||
char header[8];
|
char header[8];
|
||||||
memset(header, 0, sizeof(header));
|
memset(header, 0, sizeof(header));
|
||||||
|
@ -146,11 +145,11 @@ void DHTRoutingTableSerializer::serialize(const std::string& filename)
|
||||||
}
|
}
|
||||||
if(fp.close() == EOF) {
|
if(fp.close() == EOF) {
|
||||||
throw DL_ABORT_EX(fmt("Failed to save DHT routing table to %s.",
|
throw DL_ABORT_EX(fmt("Failed to save DHT routing table to %s.",
|
||||||
utf8ToNative(filename).c_str()));
|
filename.c_str()));
|
||||||
}
|
}
|
||||||
if(!File(filenameTemp).renameTo(filename)) {
|
if(!File(filenameTemp).renameTo(filename)) {
|
||||||
throw DL_ABORT_EX(fmt("Failed to save DHT routing table to %s.",
|
throw DL_ABORT_EX(fmt("Failed to save DHT routing table to %s.",
|
||||||
utf8ToNative(filename).c_str()));
|
filename.c_str()));
|
||||||
}
|
}
|
||||||
A2_LOG_INFO("DHT routing table was saved successfully");
|
A2_LOG_INFO("DHT routing table was saved successfully");
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,20 +104,18 @@ bool DefaultBtProgressInfoFile::isTorrentDownload()
|
||||||
|
|
||||||
#define WRITE_CHECK(fp, ptr, count) \
|
#define WRITE_CHECK(fp, ptr, count) \
|
||||||
if(fp.write((ptr), (count)) != (count)) { \
|
if(fp.write((ptr), (count)) != (count)) { \
|
||||||
throw DL_ABORT_EX \
|
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_WRITE, filename_.c_str())); \
|
||||||
(fmt(EX_SEGMENT_FILE_WRITE, utf8ToNative(filename_).c_str())); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since version 0001, Integers are saved in binary form, network byte order.
|
// Since version 0001, Integers are saved in binary form, network byte order.
|
||||||
void DefaultBtProgressInfoFile::save()
|
void DefaultBtProgressInfoFile::save()
|
||||||
{
|
{
|
||||||
A2_LOG_INFO(fmt(MSG_SAVING_SEGMENT_FILE, utf8ToNative(filename_).c_str()));
|
A2_LOG_INFO(fmt(MSG_SAVING_SEGMENT_FILE, filename_.c_str()));
|
||||||
std::string filenameTemp = filename_+"__temp";
|
std::string filenameTemp = filename_+"__temp";
|
||||||
{
|
{
|
||||||
BufferedFile fp(filenameTemp, BufferedFile::WRITE);
|
BufferedFile fp(filenameTemp, BufferedFile::WRITE);
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_WRITE, filename_.c_str()));
|
||||||
(fmt(EX_SEGMENT_FILE_WRITE, utf8ToNative(filename_).c_str()));
|
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
bool torrentDownload = isTorrentDownload();
|
bool torrentDownload = isTorrentDownload();
|
||||||
|
@ -193,21 +191,18 @@ void DefaultBtProgressInfoFile::save()
|
||||||
WRITE_CHECK(fp, (*itr)->getBitfield(), (*itr)->getBitfieldLength());
|
WRITE_CHECK(fp, (*itr)->getBitfield(), (*itr)->getBitfieldLength());
|
||||||
}
|
}
|
||||||
if(fp.close() == EOF) {
|
if(fp.close() == EOF) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_WRITE, filename_.c_str()));
|
||||||
(fmt(EX_SEGMENT_FILE_WRITE, utf8ToNative(filename_).c_str()));
|
|
||||||
}
|
}
|
||||||
A2_LOG_INFO(MSG_SAVED_SEGMENT_FILE);
|
A2_LOG_INFO(MSG_SAVED_SEGMENT_FILE);
|
||||||
}
|
}
|
||||||
if(!File(filenameTemp).renameTo(filename_)) {
|
if(!File(filenameTemp).renameTo(filename_)) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_WRITE, filename_.c_str()));
|
||||||
(fmt(EX_SEGMENT_FILE_WRITE, utf8ToNative(filename_).c_str()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ_CHECK(fp, ptr, count) \
|
#define READ_CHECK(fp, ptr, count) \
|
||||||
if(fp.read((ptr), (count)) != (count)) { \
|
if(fp.read((ptr), (count)) != (count)) { \
|
||||||
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, \
|
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, filename_.c_str())); \
|
||||||
utf8ToNative(filename_).c_str())); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is assumed that integers are saved as:
|
// It is assumed that integers are saved as:
|
||||||
|
@ -215,11 +210,10 @@ void DefaultBtProgressInfoFile::save()
|
||||||
// 2) network byte order if version == 0001
|
// 2) network byte order if version == 0001
|
||||||
void DefaultBtProgressInfoFile::load()
|
void DefaultBtProgressInfoFile::load()
|
||||||
{
|
{
|
||||||
A2_LOG_INFO(fmt(MSG_LOADING_SEGMENT_FILE, utf8ToNative(filename_).c_str()));
|
A2_LOG_INFO(fmt(MSG_LOADING_SEGMENT_FILE, filename_.c_str()));
|
||||||
BufferedFile fp(filename_, BufferedFile::READ);
|
BufferedFile fp(filename_, BufferedFile::READ);
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ,
|
throw DL_ABORT_EX(fmt(EX_SEGMENT_FILE_READ, filename_.c_str()));
|
||||||
utf8ToNative(filename_).c_str()));
|
|
||||||
}
|
}
|
||||||
unsigned char versionBuf[2];
|
unsigned char versionBuf[2];
|
||||||
READ_CHECK(fp, versionBuf, sizeof(versionBuf));
|
READ_CHECK(fp, versionBuf, sizeof(versionBuf));
|
||||||
|
@ -231,8 +225,7 @@ void DefaultBtProgressInfoFile::load()
|
||||||
version = 1;
|
version = 1;
|
||||||
} else {
|
} else {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(fmt("Unsupported ctrl file version: %s",
|
(fmt("Unsupported ctrl file version: %s", versionHex.c_str()));
|
||||||
versionHex.c_str()));
|
|
||||||
}
|
}
|
||||||
unsigned char extension[4];
|
unsigned char extension[4];
|
||||||
READ_CHECK(fp, extension, sizeof(extension));
|
READ_CHECK(fp, extension, sizeof(extension));
|
||||||
|
@ -249,8 +242,7 @@ void DefaultBtProgressInfoFile::load()
|
||||||
}
|
}
|
||||||
if((infoHashLength < 0) ||
|
if((infoHashLength < 0) ||
|
||||||
((infoHashLength == 0) && infoHashCheckEnabled)) {
|
((infoHashLength == 0) && infoHashCheckEnabled)) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX(fmt("Invalid info hash length: %d", infoHashLength));
|
||||||
(fmt("Invalid info hash length: %d", infoHashLength));
|
|
||||||
}
|
}
|
||||||
if(infoHashLength > 0) {
|
if(infoHashLength > 0) {
|
||||||
array_ptr<unsigned char> savedInfoHash(new unsigned char[infoHashLength]);
|
array_ptr<unsigned char> savedInfoHash(new unsigned char[infoHashLength]);
|
||||||
|
@ -333,8 +325,7 @@ void DefaultBtProgressInfoFile::load()
|
||||||
index = ntohl(index);
|
index = ntohl(index);
|
||||||
}
|
}
|
||||||
if(!(index < dctx_->getNumPieces())) {
|
if(!(index < dctx_->getNumPieces())) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX(fmt("piece index out of range: %u", index));
|
||||||
(fmt("piece index out of range: %u", index));
|
|
||||||
}
|
}
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
READ_CHECK(fp, &length, sizeof(length));
|
READ_CHECK(fp, &length, sizeof(length));
|
||||||
|
@ -342,8 +333,7 @@ void DefaultBtProgressInfoFile::load()
|
||||||
length = ntohl(length);
|
length = ntohl(length);
|
||||||
}
|
}
|
||||||
if(!(length <=dctx_->getPieceLength())) {
|
if(!(length <=dctx_->getPieceLength())) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX(fmt("piece length out of range: %u", length));
|
||||||
(fmt("piece length out of range: %u", length));
|
|
||||||
}
|
}
|
||||||
SharedHandle<Piece> piece(new Piece(index, length));
|
SharedHandle<Piece> piece(new Piece(index, length));
|
||||||
uint32_t bitfieldLength;
|
uint32_t bitfieldLength;
|
||||||
|
@ -408,12 +398,10 @@ bool DefaultBtProgressInfoFile::exists()
|
||||||
{
|
{
|
||||||
File f(filename_);
|
File f(filename_);
|
||||||
if(f.isFile()) {
|
if(f.isFile()) {
|
||||||
A2_LOG_INFO(fmt(MSG_SEGMENT_FILE_EXISTS,
|
A2_LOG_INFO(fmt(MSG_SEGMENT_FILE_EXISTS, filename_.c_str()));
|
||||||
utf8ToNative(filename_).c_str()));
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
A2_LOG_INFO(fmt(MSG_SEGMENT_FILE_DOES_NOT_EXIST,
|
A2_LOG_INFO(fmt(MSG_SEGMENT_FILE_DOES_NOT_EXIST, filename_.c_str()));
|
||||||
utf8ToNative(filename_).c_str()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,14 +148,13 @@ bool File::mkdirs() {
|
||||||
}
|
}
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
std::string dir = std::string(begin, j);
|
std::string dir = std::string(begin, j);
|
||||||
A2_LOG_DEBUG(fmt("Making directory %s", utf8ToNative(dir).c_str()));
|
A2_LOG_DEBUG(fmt("Making directory %s", dir.c_str()));
|
||||||
if(File(dir).isDir()) {
|
if(File(dir).isDir()) {
|
||||||
A2_LOG_DEBUG(fmt("%s exists and is a directory.",
|
A2_LOG_DEBUG(fmt("%s exists and is a directory.", dir.c_str()));
|
||||||
utf8ToNative(dir).c_str()));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(a2mkdir(utf8ToWChar(dir).c_str(), DIR_OPEN_MODE) == -1) {
|
if(a2mkdir(utf8ToWChar(dir).c_str(), DIR_OPEN_MODE) == -1) {
|
||||||
A2_LOG_DEBUG(fmt("Failed to create %s", utf8ToNative(dir).c_str()));
|
A2_LOG_DEBUG(fmt("Failed to create %s", dir.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,8 +96,7 @@ bool FileAllocationCommand::handleException(Exception& e)
|
||||||
A2_LOG_ERROR
|
A2_LOG_ERROR
|
||||||
(fmt(MSG_DOWNLOAD_NOT_COMPLETE,
|
(fmt(MSG_DOWNLOAD_NOT_COMPLETE,
|
||||||
getCuid(),
|
getCuid(),
|
||||||
utf8ToNative(getRequestGroup()->getDownloadContext()
|
getRequestGroup()->getDownloadContext()->getBasePath().c_str()));
|
||||||
->getBasePath()).c_str()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,7 @@ void FileEntry::removeURIWhoseHostnameIs(const std::string& hostname)
|
||||||
}
|
}
|
||||||
A2_LOG_DEBUG(fmt("Removed %lu duplicate hostname URIs for path=%s",
|
A2_LOG_DEBUG(fmt("Removed %lu duplicate hostname URIs for path=%s",
|
||||||
static_cast<unsigned long>(uris_.size()-newURIs.size()),
|
static_cast<unsigned long>(uris_.size()-newURIs.size()),
|
||||||
utf8ToNative(getPath()).c_str()));
|
getPath().c_str()));
|
||||||
uris_.swap(newURIs);
|
uris_.swap(newURIs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -376,7 +376,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
|
||||||
isSameFileBeingDownloaded(getRequestGroup())) {
|
isSameFileBeingDownloaded(getRequestGroup())) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
utf8ToNative(getRequestGroup()->getFirstFilePath()).c_str()),
|
getRequestGroup()->getFirstFilePath().c_str()),
|
||||||
error_code::DUPLICATE_DOWNLOAD);
|
error_code::DUPLICATE_DOWNLOAD);
|
||||||
}
|
}
|
||||||
if(totalLength == 0) {
|
if(totalLength == 0) {
|
||||||
|
@ -407,7 +407,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
|
||||||
A2_LOG_NOTICE
|
A2_LOG_NOTICE
|
||||||
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
||||||
util::itos(getRequestGroup()->getGID()).c_str(),
|
util::itos(getRequestGroup()->getGID()).c_str(),
|
||||||
utf8ToNative(getRequestGroup()->getFirstFilePath()).c_str()));
|
getRequestGroup()->getFirstFilePath().c_str()));
|
||||||
poolConnection();
|
poolConnection();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -189,7 +189,7 @@ bool HttpResponseCommand::executeInternal()
|
||||||
A2_LOG_NOTICE
|
A2_LOG_NOTICE
|
||||||
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
||||||
util::itos(getRequestGroup()->getGID()).c_str(),
|
util::itos(getRequestGroup()->getGID()).c_str(),
|
||||||
utf8ToNative(getRequestGroup()->getFirstFilePath()).c_str()));
|
getRequestGroup()->getFirstFilePath().c_str()));
|
||||||
poolConnection();
|
poolConnection();
|
||||||
getFileEntry()->poolRequest(getRequest());
|
getFileEntry()->poolRequest(getRequest());
|
||||||
return true;
|
return true;
|
||||||
|
@ -258,7 +258,7 @@ bool HttpResponseCommand::executeInternal()
|
||||||
isSameFileBeingDownloaded(getRequestGroup())) {
|
isSameFileBeingDownloaded(getRequestGroup())) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
utf8ToNative(getRequestGroup()->getFirstFilePath()).c_str()),
|
getRequestGroup()->getFirstFilePath().c_str()),
|
||||||
error_code::DUPLICATE_DOWNLOAD);
|
error_code::DUPLICATE_DOWNLOAD);
|
||||||
}
|
}
|
||||||
// update last modified time
|
// update last modified time
|
||||||
|
@ -442,7 +442,7 @@ bool HttpResponseCommand::handleOtherEncoding
|
||||||
A2_LOG_NOTICE
|
A2_LOG_NOTICE
|
||||||
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
||||||
util::itos(getRequestGroup()->getGID()).c_str(),
|
util::itos(getRequestGroup()->getGID()).c_str(),
|
||||||
utf8ToNative(getRequestGroup()->getFirstFilePath()).c_str()));
|
getRequestGroup()->getFirstFilePath().c_str()));
|
||||||
poolConnection();
|
poolConnection();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ std::string IteratableChunkChecksumValidator::digest(off_t offset, size_t length
|
||||||
curoffset);
|
curoffset);
|
||||||
if(r == 0 || r < static_cast<size_t>(woffset)) {
|
if(r == 0 || r < static_cast<size_t>(woffset)) {
|
||||||
throw DL_ABORT_EX
|
throw DL_ABORT_EX
|
||||||
(fmt(EX_FILE_READ, utf8ToNative(dctx_->getBasePath()).c_str(),
|
(fmt(EX_FILE_READ, dctx_->getBasePath().c_str(),
|
||||||
"data is too short"));
|
"data is too short"));
|
||||||
}
|
}
|
||||||
size_t wlength;
|
size_t wlength;
|
||||||
|
|
|
@ -77,7 +77,7 @@ void Logger::openFile(const std::string& filename)
|
||||||
closeFile();
|
closeFile();
|
||||||
fpp_ = new BufferedFile(filename, BufferedFile::APPEND);
|
fpp_ = new BufferedFile(filename, BufferedFile::APPEND);
|
||||||
if(!fpp_) {
|
if(!fpp_) {
|
||||||
throw DL_ABORT_EX(fmt(EX_FILE_OPEN, utf8ToNative(filename).c_str(), "n/a"));
|
throw DL_ABORT_EX(fmt(EX_FILE_OPEN, filename.c_str(), "n/a"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,8 +197,7 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
entryGroups.begin(), eoi = entryGroups.end(); itr != eoi; ++itr) {
|
entryGroups.begin(), eoi = entryGroups.end(); itr != eoi; ++itr) {
|
||||||
const std::string& metaurl = (*itr).first;
|
const std::string& metaurl = (*itr).first;
|
||||||
const std::vector<SharedHandle<MetalinkEntry> >& mes = (*itr).second;
|
const std::vector<SharedHandle<MetalinkEntry> >& mes = (*itr).second;
|
||||||
A2_LOG_INFO(fmt("Processing metaurl group metaurl=%s",
|
A2_LOG_INFO(fmt("Processing metaurl group metaurl=%s", metaurl.c_str()));
|
||||||
utf8ToNative(metaurl).c_str()));
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
SharedHandle<RequestGroup> torrentRg;
|
SharedHandle<RequestGroup> torrentRg;
|
||||||
if(!metaurl.empty()) {
|
if(!metaurl.empty()) {
|
||||||
|
@ -234,8 +233,7 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
SharedHandle<DownloadContext> dctx;
|
SharedHandle<DownloadContext> dctx;
|
||||||
if(mes.size() == 1) {
|
if(mes.size() == 1) {
|
||||||
SharedHandle<MetalinkEntry> entry = mes[0];
|
SharedHandle<MetalinkEntry> entry = mes[0];
|
||||||
A2_LOG_INFO(fmt(MSG_METALINK_QUEUEING,
|
A2_LOG_INFO(fmt(MSG_METALINK_QUEUEING, entry->getPath().c_str()));
|
||||||
utf8ToNative(entry->getPath()).c_str()));
|
|
||||||
entry->reorderResourcesByPriority();
|
entry->reorderResourcesByPriority();
|
||||||
std::vector<std::string> uris;
|
std::vector<std::string> uris;
|
||||||
std::for_each(entry->resources.begin(), entry->resources.end(),
|
std::for_each(entry->resources.begin(), entry->resources.end(),
|
||||||
|
@ -289,9 +287,8 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
for(std::vector<SharedHandle<MetalinkEntry> >::const_iterator i =
|
for(std::vector<SharedHandle<MetalinkEntry> >::const_iterator i =
|
||||||
mes.begin(), eoi = mes.end(); i != eoi; ++i) {
|
mes.begin(), eoi = mes.end(); i != eoi; ++i) {
|
||||||
A2_LOG_INFO(fmt("Metalink: Queueing %s for download as a member.",
|
A2_LOG_INFO(fmt("Metalink: Queueing %s for download as a member.",
|
||||||
utf8ToNative((*i)->getPath()).c_str()));
|
(*i)->getPath().c_str()));
|
||||||
A2_LOG_DEBUG(fmt("originalName = %s",
|
A2_LOG_DEBUG(fmt("originalName = %s", (*i)->metaurls[0]->name.c_str()));
|
||||||
utf8ToNative((*i)->metaurls[0]->name).c_str()));
|
|
||||||
(*i)->reorderResourcesByPriority();
|
(*i)->reorderResourcesByPriority();
|
||||||
std::vector<std::string> uris;
|
std::vector<std::string> uris;
|
||||||
std::for_each((*i)->resources.begin(), (*i)->resources.end(),
|
std::for_each((*i)->resources.begin(), (*i)->resources.end(),
|
||||||
|
|
|
@ -97,7 +97,7 @@ void MetalinkPostDownloadHandler::getNextRequestGroups
|
||||||
RequestGroup* requestGroup)
|
RequestGroup* requestGroup)
|
||||||
{
|
{
|
||||||
A2_LOG_DEBUG(fmt("Generating RequestGroups for Metalink file %s",
|
A2_LOG_DEBUG(fmt("Generating RequestGroups for Metalink file %s",
|
||||||
utf8ToNative(requestGroup->getFirstFilePath()).c_str()));
|
requestGroup->getFirstFilePath().c_str()));
|
||||||
SharedHandle<DiskAdaptor> diskAdaptor =
|
SharedHandle<DiskAdaptor> diskAdaptor =
|
||||||
requestGroup->getPieceStorage()->getDiskAdaptor();
|
requestGroup->getPieceStorage()->getDiskAdaptor();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -187,7 +187,7 @@ void MultiDiskAdaptor::resetDiskWriterEntries()
|
||||||
pieceLength_*pieceLength_;
|
pieceLength_*pieceLength_;
|
||||||
A2_LOG_DEBUG(fmt("Checking adjacent backward file to %s"
|
A2_LOG_DEBUG(fmt("Checking adjacent backward file to %s"
|
||||||
" whose lastPieceStartOffset+pieceLength_=%lld",
|
" whose lastPieceStartOffset+pieceLength_=%lld",
|
||||||
utf8ToNative(fileEntry->getPath()).c_str(),
|
fileEntry->getPath().c_str(),
|
||||||
static_cast<long long int>
|
static_cast<long long int>
|
||||||
(lastPieceStartOffset+pieceLength_)));
|
(lastPieceStartOffset+pieceLength_)));
|
||||||
++itr;
|
++itr;
|
||||||
|
@ -198,14 +198,14 @@ void MultiDiskAdaptor::resetDiskWriterEntries()
|
||||||
(*itr)->getFileEntry()->getLength() == 0); ++itr) {
|
(*itr)->getFileEntry()->getLength() == 0); ++itr) {
|
||||||
A2_LOG_DEBUG
|
A2_LOG_DEBUG
|
||||||
(fmt("file=%s, offset=%lld",
|
(fmt("file=%s, offset=%lld",
|
||||||
utf8ToNative((*itr)->getFileEntry()->getPath()).c_str(),
|
(*itr)->getFileEntry()->getPath().c_str(),
|
||||||
static_cast<long long int>
|
static_cast<long long int>
|
||||||
((*itr)->getFileEntry()->getOffset())));
|
((*itr)->getFileEntry()->getOffset())));
|
||||||
if((*itr)->getFileEntry()->getOffset() <
|
if((*itr)->getFileEntry()->getOffset() <
|
||||||
static_cast<off_t>(lastPieceStartOffset+pieceLength_)) {
|
static_cast<off_t>(lastPieceStartOffset+pieceLength_)) {
|
||||||
A2_LOG_DEBUG
|
A2_LOG_DEBUG
|
||||||
(fmt("%s needs diskwriter",
|
(fmt("%s needs diskwriter",
|
||||||
utf8ToNative((*itr)->getFileEntry()->getPath()).c_str()));
|
(*itr)->getFileEntry()->getPath().c_str()));
|
||||||
dwreq[(*itr)->getFileEntry()->getPath()] = true;
|
dwreq[(*itr)->getFileEntry()->getPath()] = true;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -226,7 +226,7 @@ void MultiDiskAdaptor::resetDiskWriterEntries()
|
||||||
dwreq.find((*i)->getFileEntry()->getPath()) != dwreq.end() ||
|
dwreq.find((*i)->getFileEntry()->getPath()) != dwreq.end() ||
|
||||||
(*i)->fileExists()) {
|
(*i)->fileExists()) {
|
||||||
A2_LOG_DEBUG(fmt("Creating DiskWriter for filename=%s",
|
A2_LOG_DEBUG(fmt("Creating DiskWriter for filename=%s",
|
||||||
utf8ToNative((*i)->getFilePath()).c_str()));
|
(*i)->getFilePath().c_str()));
|
||||||
(*i)->setDiskWriter(dwFactory.newDiskWriter((*i)->getFilePath()));
|
(*i)->setDiskWriter(dwFactory.newDiskWriter((*i)->getFilePath()));
|
||||||
if(readOnly_) {
|
if(readOnly_) {
|
||||||
(*i)->getDiskWriter()->enableReadOnly();
|
(*i)->getDiskWriter()->enableReadOnly();
|
||||||
|
|
|
@ -139,7 +139,7 @@ void Netrc::parse(const std::string& path)
|
||||||
authenticators_.clear();
|
authenticators_.clear();
|
||||||
BufferedFile fp(path, BufferedFile::READ);
|
BufferedFile fp(path, BufferedFile::READ);
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
throw DL_ABORT_EX(fmt("Cannot open file: %s", utf8ToNative(path).c_str()));
|
throw DL_ABORT_EX(fmt("Cannot open file: %s", path.c_str()));
|
||||||
}
|
}
|
||||||
enum STATE {
|
enum STATE {
|
||||||
GET_TOKEN,
|
GET_TOKEN,
|
||||||
|
|
|
@ -98,8 +98,7 @@ std::vector<Cookie> NsCookieParser::parse
|
||||||
{
|
{
|
||||||
BufferedFile fp(filename, BufferedFile::READ);
|
BufferedFile fp(filename, BufferedFile::READ);
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
throw DL_ABORT_EX(fmt("Failed to open file %s",
|
throw DL_ABORT_EX(fmt("Failed to open file %s", filename.c_str()));
|
||||||
utf8ToNative(filename).c_str()));
|
|
||||||
}
|
}
|
||||||
std::vector<Cookie> cookies;
|
std::vector<Cookie> cookies;
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
|
|
|
@ -249,7 +249,7 @@ SharedHandle<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
|
||||||
A2_LOG_NOTICE
|
A2_LOG_NOTICE
|
||||||
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
||||||
util::itos(gid_).c_str(),
|
util::itos(gid_).c_str(),
|
||||||
utf8ToNative(downloadContext_->getBasePath()).c_str()));
|
downloadContext_->getBasePath().c_str()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
checkEntry.reset(new StreamCheckIntegrityEntry(this));
|
checkEntry.reset(new StreamCheckIntegrityEntry(this));
|
||||||
|
@ -271,7 +271,7 @@ SharedHandle<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
|
||||||
A2_LOG_NOTICE
|
A2_LOG_NOTICE
|
||||||
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
||||||
util::itos(gid_).c_str(),
|
util::itos(gid_).c_str(),
|
||||||
utf8ToNative(downloadContext_->getBasePath()).c_str()));
|
downloadContext_->getBasePath().c_str()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
loadAndOpenFile(infoFile);
|
loadAndOpenFile(infoFile);
|
||||||
|
@ -314,7 +314,7 @@ void RequestGroup::createInitialCommand
|
||||||
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
utf8ToNative(downloadContext_->getBasePath()).c_str()),
|
downloadContext_->getBasePath().c_str()),
|
||||||
error_code::DUPLICATE_DOWNLOAD);
|
error_code::DUPLICATE_DOWNLOAD);
|
||||||
}
|
}
|
||||||
initPieceStorage();
|
initPieceStorage();
|
||||||
|
@ -421,7 +421,7 @@ void RequestGroup::createInitialCommand
|
||||||
// TODO we need this->haltRequested = true?
|
// TODO we need this->haltRequested = true?
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt(MSG_FILE_ALREADY_EXISTS,
|
(fmt(MSG_FILE_ALREADY_EXISTS,
|
||||||
utf8ToNative(downloadContext_->getBasePath()).c_str()),
|
downloadContext_->getBasePath().c_str()),
|
||||||
error_code::FILE_ALREADY_EXISTS);
|
error_code::FILE_ALREADY_EXISTS);
|
||||||
} else {
|
} else {
|
||||||
pieceStorage_->getDiskAdaptor()->openFile();
|
pieceStorage_->getDiskAdaptor()->openFile();
|
||||||
|
@ -486,7 +486,7 @@ void RequestGroup::createInitialCommand
|
||||||
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
utf8ToNative(downloadContext_->getBasePath()).c_str()),
|
downloadContext_->getBasePath().c_str()),
|
||||||
error_code::DUPLICATE_DOWNLOAD);
|
error_code::DUPLICATE_DOWNLOAD);
|
||||||
}
|
}
|
||||||
SharedHandle<BtProgressInfoFile> progressInfoFile
|
SharedHandle<BtProgressInfoFile> progressInfoFile
|
||||||
|
@ -513,7 +513,7 @@ void RequestGroup::createInitialCommand
|
||||||
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
||||||
utf8ToNative(downloadContext_->getBasePath()).c_str()),
|
downloadContext_->getBasePath().c_str()),
|
||||||
error_code::DUPLICATE_DOWNLOAD);
|
error_code::DUPLICATE_DOWNLOAD);
|
||||||
}
|
}
|
||||||
initPieceStorage();
|
initPieceStorage();
|
||||||
|
@ -537,7 +537,7 @@ void RequestGroup::createInitialCommand
|
||||||
// TODO we need this->haltRequested = true?
|
// TODO we need this->haltRequested = true?
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt(MSG_FILE_ALREADY_EXISTS,
|
(fmt(MSG_FILE_ALREADY_EXISTS,
|
||||||
utf8ToNative(downloadContext_->getBasePath()).c_str()),
|
downloadContext_->getBasePath().c_str()),
|
||||||
error_code::FILE_ALREADY_EXISTS);
|
error_code::FILE_ALREADY_EXISTS);
|
||||||
} else {
|
} else {
|
||||||
pieceStorage_->getDiskAdaptor()->openFile();
|
pieceStorage_->getDiskAdaptor()->openFile();
|
||||||
|
@ -722,7 +722,7 @@ void RequestGroup::removeDefunctControlFile
|
||||||
progressInfoFile->removeFile();
|
progressInfoFile->removeFile();
|
||||||
A2_LOG_NOTICE(fmt(MSG_REMOVED_DEFUNCT_CONTROL_FILE,
|
A2_LOG_NOTICE(fmt(MSG_REMOVED_DEFUNCT_CONTROL_FILE,
|
||||||
progressInfoFile->getFilename().c_str(),
|
progressInfoFile->getFilename().c_str(),
|
||||||
utf8ToNative(downloadContext_->getBasePath()).c_str()));
|
downloadContext_->getBasePath().c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,18 +771,15 @@ void RequestGroup::shouldCancelDownloadForSafety()
|
||||||
if(outfile.exists()) {
|
if(outfile.exists()) {
|
||||||
if(option_->getAsBool(PREF_AUTO_FILE_RENAMING)) {
|
if(option_->getAsBool(PREF_AUTO_FILE_RENAMING)) {
|
||||||
if(tryAutoFileRenaming()) {
|
if(tryAutoFileRenaming()) {
|
||||||
A2_LOG_NOTICE(fmt(MSG_FILE_RENAMED,
|
A2_LOG_NOTICE(fmt(MSG_FILE_RENAMED, getFirstFilePath().c_str()));
|
||||||
utf8ToNative(getFirstFilePath()).c_str()));
|
|
||||||
} else {
|
} else {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt("File renaming failed: %s",
|
(fmt("File renaming failed: %s", getFirstFilePath().c_str()),
|
||||||
utf8ToNative(getFirstFilePath()).c_str()),
|
|
||||||
error_code::FILE_RENAMING_FAILED);
|
error_code::FILE_RENAMING_FAILED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw DOWNLOAD_FAILURE_EXCEPTION2
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
||||||
(fmt(MSG_FILE_ALREADY_EXISTS,
|
(fmt(MSG_FILE_ALREADY_EXISTS, getFirstFilePath().c_str()),
|
||||||
utf8ToNative(getFirstFilePath()).c_str()),
|
|
||||||
error_code::FILE_ALREADY_EXISTS);
|
error_code::FILE_ALREADY_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1039,7 +1036,7 @@ void RequestGroup::releaseRuntimeResource(DownloadEngine* e)
|
||||||
void RequestGroup::preDownloadProcessing()
|
void RequestGroup::preDownloadProcessing()
|
||||||
{
|
{
|
||||||
A2_LOG_DEBUG(fmt("Finding PreDownloadHandler for path %s.",
|
A2_LOG_DEBUG(fmt("Finding PreDownloadHandler for path %s.",
|
||||||
utf8ToNative(getFirstFilePath()).c_str()));
|
getFirstFilePath().c_str()));
|
||||||
try {
|
try {
|
||||||
for(std::vector<SharedHandle<PreDownloadHandler> >::const_iterator itr =
|
for(std::vector<SharedHandle<PreDownloadHandler> >::const_iterator itr =
|
||||||
preDownloadHandlers_.begin(), eoi = preDownloadHandlers_.end();
|
preDownloadHandlers_.begin(), eoi = preDownloadHandlers_.end();
|
||||||
|
@ -1061,7 +1058,7 @@ void RequestGroup::postDownloadProcessing
|
||||||
(std::vector<SharedHandle<RequestGroup> >& groups)
|
(std::vector<SharedHandle<RequestGroup> >& groups)
|
||||||
{
|
{
|
||||||
A2_LOG_DEBUG(fmt("Finding PostDownloadHandler for path %s.",
|
A2_LOG_DEBUG(fmt("Finding PostDownloadHandler for path %s.",
|
||||||
utf8ToNative(getFirstFilePath()).c_str()));
|
getFirstFilePath().c_str()));
|
||||||
try {
|
try {
|
||||||
for(std::vector<SharedHandle<PostDownloadHandler> >::const_iterator itr =
|
for(std::vector<SharedHandle<PostDownloadHandler> >::const_iterator itr =
|
||||||
postDownloadHandlers_.begin(), eoi = postDownloadHandlers_.end();
|
postDownloadHandlers_.begin(), eoi = postDownloadHandlers_.end();
|
||||||
|
@ -1203,7 +1200,7 @@ DownloadResultHandle RequestGroup::createDownloadResult() const
|
||||||
void RequestGroup::reportDownloadFinished()
|
void RequestGroup::reportDownloadFinished()
|
||||||
{
|
{
|
||||||
A2_LOG_NOTICE(fmt(MSG_FILE_DOWNLOAD_COMPLETED,
|
A2_LOG_NOTICE(fmt(MSG_FILE_DOWNLOAD_COMPLETED,
|
||||||
utf8ToNative(downloadContext_->getBasePath()).c_str()));
|
downloadContext_->getBasePath().c_str()));
|
||||||
uriSelector_->resetCounters();
|
uriSelector_->resetCounters();
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) {
|
if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) {
|
||||||
|
|
|
@ -343,8 +343,7 @@ public:
|
||||||
A2_LOG_NOTICE
|
A2_LOG_NOTICE
|
||||||
(fmt("Download GID#%s not complete: %s",
|
(fmt("Download GID#%s not complete: %s",
|
||||||
util::itos(group->getGID()).c_str(),
|
util::itos(group->getGID()).c_str(),
|
||||||
utf8ToNative(group->getDownloadContext()
|
group->getDownloadContext()->getBasePath().c_str()));
|
||||||
->getBasePath()).c_str()));
|
|
||||||
group->saveControlFile();
|
group->saveControlFile();
|
||||||
}
|
}
|
||||||
} catch(RecoverableException& ex) {
|
} catch(RecoverableException& ex) {
|
||||||
|
|
|
@ -471,7 +471,7 @@ size_t SegmentMan::countFreePieceFrom(size_t index) const
|
||||||
void SegmentMan::ignoreSegmentFor(const SharedHandle<FileEntry>& fileEntry)
|
void SegmentMan::ignoreSegmentFor(const SharedHandle<FileEntry>& fileEntry)
|
||||||
{
|
{
|
||||||
A2_LOG_DEBUG(fmt("ignoring segment for path=%s, offset=%s, length=%s",
|
A2_LOG_DEBUG(fmt("ignoring segment for path=%s, offset=%s, length=%s",
|
||||||
utf8ToNative(fileEntry->getPath()).c_str(),
|
fileEntry->getPath().c_str(),
|
||||||
util::itos(fileEntry->getOffset()).c_str(),
|
util::itos(fileEntry->getOffset()).c_str(),
|
||||||
util::uitos(fileEntry->getLength()).c_str()));
|
util::uitos(fileEntry->getLength()).c_str()));
|
||||||
ignoreBitfield_.addFilter(fileEntry->getOffset(), fileEntry->getLength());
|
ignoreBitfield_.addFilter(fileEntry->getOffset(), fileEntry->getLength());
|
||||||
|
|
|
@ -94,7 +94,7 @@ bool ServerStatMan::save(const std::string& filename) const
|
||||||
BufferedFile fp(tempfile, BufferedFile::WRITE);
|
BufferedFile fp(tempfile, BufferedFile::WRITE);
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
A2_LOG_ERROR(fmt(MSG_OPENING_WRITABLE_SERVER_STAT_FILE_FAILED,
|
A2_LOG_ERROR(fmt(MSG_OPENING_WRITABLE_SERVER_STAT_FILE_FAILED,
|
||||||
utf8ToNative(filename).c_str()));
|
filename.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(std::deque<SharedHandle<ServerStat> >::const_iterator i =
|
for(std::deque<SharedHandle<ServerStat> >::const_iterator i =
|
||||||
|
@ -103,22 +103,19 @@ bool ServerStatMan::save(const std::string& filename) const
|
||||||
l += "\n";
|
l += "\n";
|
||||||
if(fp.write(l.data(), l.size()) != l.size()) {
|
if(fp.write(l.data(), l.size()) != l.size()) {
|
||||||
A2_LOG_ERROR(fmt(MSG_WRITING_SERVER_STAT_FILE_FAILED,
|
A2_LOG_ERROR(fmt(MSG_WRITING_SERVER_STAT_FILE_FAILED,
|
||||||
utf8ToNative(filename).c_str()));
|
filename.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(fp.close() == EOF) {
|
if(fp.close() == EOF) {
|
||||||
A2_LOG_ERROR(fmt(MSG_WRITING_SERVER_STAT_FILE_FAILED,
|
A2_LOG_ERROR(fmt(MSG_WRITING_SERVER_STAT_FILE_FAILED, filename.c_str()));
|
||||||
utf8ToNative(filename).c_str()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(File(tempfile).renameTo(filename)) {
|
if(File(tempfile).renameTo(filename)) {
|
||||||
A2_LOG_NOTICE(fmt(MSG_SERVER_STAT_SAVED,
|
A2_LOG_NOTICE(fmt(MSG_SERVER_STAT_SAVED, filename.c_str()));
|
||||||
utf8ToNative(filename).c_str()));
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
A2_LOG_ERROR(fmt(MSG_WRITING_SERVER_STAT_FILE_FAILED,
|
A2_LOG_ERROR(fmt(MSG_WRITING_SERVER_STAT_FILE_FAILED, filename.c_str()));
|
||||||
utf8ToNative(filename).c_str()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +134,7 @@ bool ServerStatMan::load(const std::string& filename)
|
||||||
BufferedFile fp(filename, BufferedFile::READ);
|
BufferedFile fp(filename, BufferedFile::READ);
|
||||||
if(!fp) {
|
if(!fp) {
|
||||||
A2_LOG_ERROR(fmt(MSG_OPENING_READABLE_SERVER_STAT_FILE_FAILED,
|
A2_LOG_ERROR(fmt(MSG_OPENING_READABLE_SERVER_STAT_FILE_FAILED,
|
||||||
utf8ToNative(filename).c_str()));
|
filename.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
@ -147,7 +144,7 @@ bool ServerStatMan::load(const std::string& filename)
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
A2_LOG_ERROR(fmt(MSG_READING_SERVER_STAT_FILE_FAILED,
|
A2_LOG_ERROR(fmt(MSG_READING_SERVER_STAT_FILE_FAILED,
|
||||||
utf8ToNative(filename).c_str()));
|
filename.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +188,7 @@ bool ServerStatMan::load(const std::string& filename)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
A2_LOG_NOTICE(fmt(MSG_SERVER_STAT_LOADED, utf8ToNative(filename).c_str()));
|
A2_LOG_NOTICE(fmt(MSG_SERVER_STAT_LOADED, filename.c_str()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ std::wstring utf8ToWChar(const std::string& src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string utf8ToNative(const std::string& src)
|
std::string const std::string& src
|
||||||
{
|
{
|
||||||
std::wstring wsrc = utf8ToWChar(src);
|
std::wstring wsrc = utf8ToWChar(src);
|
||||||
int len = wCharToAnsi(0, 0, wsrc);
|
int len = wCharToAnsi(0, 0, wsrc);
|
||||||
|
@ -1286,7 +1286,7 @@ void mkdirs(const std::string& dirpath)
|
||||||
if(!dir.isDir()) {
|
if(!dir.isDir()) {
|
||||||
throw DL_ABORT_EX3
|
throw DL_ABORT_EX3
|
||||||
(errNum,
|
(errNum,
|
||||||
fmt(EX_MAKE_DIR, utf8ToNative(dir.getPath()).c_str(),
|
fmt(EX_MAKE_DIR, dir.getPath().c_str(),
|
||||||
safeStrerror(errNum).c_str()),
|
safeStrerror(errNum).c_str()),
|
||||||
error_code::DIR_CREATE_ERROR);
|
error_code::DIR_CREATE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue