http: 修复32位系统下,下载3GB以上文件失败的问题: #1446

This commit is contained in:
ziyue 2022-02-23 17:03:13 +08:00
parent 4a7f5796ba
commit b2bb37dc5c
3 changed files with 11 additions and 14 deletions

@ -1 +1 @@
Subproject commit 6a661111ea029538e1fafa505cb6e8bba8c95551 Subproject commit 9d3124047d1ec64bf1674ae71bd4fddd728d2243

View File

@ -205,7 +205,7 @@ int64_t HttpFileBody::remainSize() {
} }
Buffer::Ptr HttpFileBody::readData(size_t size) { Buffer::Ptr HttpFileBody::readData(size_t size) {
size = MIN((size_t)remainSize(), size); size = (size_t)(MIN(remainSize(), (int64_t)size));
if (!size) { if (!size) {
//没有剩余字节了 //没有剩余字节了
return nullptr; return nullptr;

View File

@ -159,18 +159,15 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st
continue; continue;
} }
//是文件 //是文件
struct stat fileData; auto fileSize = File::fileSize(strAbsolutePath.data());
if (0 == stat(strAbsolutePath.data(), &fileData)) { if (fileSize < 1024) {
auto &fileSize = fileData.st_size; ss << " (" << fileSize << "B)" << endl;
if (fileSize < 1024) { } else if (fileSize < 1024 * 1024) {
ss << " (" << fileData.st_size << "B)" << endl; ss << fixed << setprecision(2) << " (" << fileSize / 1024.0 << "KB)";
} else if (fileSize < 1024 * 1024) { } else if (fileSize < 1024 * 1024 * 1024) {
ss << fixed << setprecision(2) << " (" << fileData.st_size / 1024.0 << "KB)"; ss << fixed << setprecision(2) << " (" << fileSize / 1024 / 1024.0 << "MB)";
} else if (fileSize < 1024 * 1024 * 1024) { } else {
ss << fixed << setprecision(2) << " (" << fileData.st_size / 1024 / 1024.0 << "MB)"; ss << fixed << setprecision(2) << " (" << fileSize / 1024 / 1024 / 1024.0 << "GB)";
} else {
ss << fixed << setprecision(2) << " (" << fileData.st_size / 1024 / 1024 / 1024.0 << "GB)";
}
} }
ss << "</a></li>\r\n"; ss << "</a></li>\r\n";
} }