mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-24 10:33:15 +08:00
improve geo download
This commit is contained in:
parent
fa06493aa9
commit
fec85a54ec
@ -55,11 +55,15 @@ namespace NekoGui_network {
|
|||||||
{"https", "127.0.0.1:" + QString(Int2String(NekoGui::dataStore->inbound_socks_port)).toStdString()}});
|
{"https", "127.0.0.1:" + QString(Int2String(NekoGui::dataStore->inbound_socks_port)).toStdString()}});
|
||||||
}
|
}
|
||||||
auto filePath = NekoGui::GetBasePath()+ "/" + fileName;
|
auto filePath = NekoGui::GetBasePath()+ "/" + fileName;
|
||||||
|
auto tempFilePath = QString(filePath + ".1");
|
||||||
|
QFile::remove(tempFilePath);
|
||||||
|
|
||||||
std::ofstream fout;
|
std::ofstream fout;
|
||||||
fout.open(QString(filePath + ".1").toStdString(), std::ios::trunc | std::ios::out | std::ios::binary);
|
fout.open(tempFilePath.toStdString(), std::ios::trunc | std::ios::out | std::ios::binary);
|
||||||
auto r = session.Download(fout);
|
auto r = session.Download(fout);
|
||||||
fout.close();
|
fout.close();
|
||||||
auto tmpFile = QFile(filePath + ".1");
|
|
||||||
|
auto tmpFile = QFile(tempFilePath);
|
||||||
if (r.status_code != 200) {
|
if (r.status_code != 200) {
|
||||||
tmpFile.remove();
|
tmpFile.remove();
|
||||||
if (r.status_code == 0) {
|
if (r.status_code == 0) {
|
||||||
@ -69,6 +73,7 @@ namespace NekoGui_network {
|
|||||||
}
|
}
|
||||||
QFile(filePath).remove();
|
QFile(filePath).remove();
|
||||||
if (!tmpFile.rename(filePath)) {
|
if (!tmpFile.rename(filePath)) {
|
||||||
|
tmpFile.remove();
|
||||||
return tmpFile.errorString();
|
return tmpFile.errorString();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user