mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06:00
Improve error detection when saving files
This commit is contained in:
@@ -47,9 +47,7 @@ namespace
|
||||
QFile file {filePath};
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
return false;
|
||||
|
||||
file.write(replyData);
|
||||
return true;
|
||||
return (file.write(replyData) == replyData.length());
|
||||
}
|
||||
|
||||
QTemporaryFile tmpfile {Utils::Fs::tempPath() + "XXXXXX"};
|
||||
@@ -59,9 +57,7 @@ namespace
|
||||
return false;
|
||||
|
||||
filePath = tmpfile.fileName();
|
||||
|
||||
tmpfile.write(replyData);
|
||||
return true;
|
||||
return (tmpfile.write(replyData) == replyData.length());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -451,11 +451,17 @@ void GeoIPManager::downloadFinished(const DownloadResult &result)
|
||||
specialFolderLocation(SpecialFolder::Data) + GEODB_FOLDER);
|
||||
if (!QDir(targetPath).exists())
|
||||
QDir().mkpath(targetPath);
|
||||
|
||||
QFile targetFile(QString::fromLatin1("%1/%2").arg(targetPath, GEODB_FILENAME));
|
||||
if (!targetFile.open(QFile::WriteOnly) || (targetFile.write(data) == -1))
|
||||
LogMsg(tr("Couldn't save downloaded IP geolocation database file."), Log::WARNING);
|
||||
if (!targetFile.open(QFile::WriteOnly) || (targetFile.write(data) != data.length()))
|
||||
{
|
||||
LogMsg(tr("Couldn't save downloaded IP geolocation database file. Reason: %1")
|
||||
.arg(targetFile.errorString()), Log::WARNING);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogMsg(tr("Successfully updated IP geolocation database."), Log::INFO);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user