MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / saveFile

Method saveFile

lib/QSimpleUpdater/src/Downloader.cpp:339–360  ·  view source on GitHub ↗

* @brief Writes the downloaded data to the disk. */

Source from the content-addressed store, hash-verified

337 * @brief Writes the downloaded data to the disk.
338 */
339void Downloader::saveFile(qint64 received, qint64 total)
340{
341 Q_UNUSED(received);
342 Q_UNUSED(total);
343
344 if (!m_reply)
345 return;
346
347 // Check if we need to redirect
348 QUrl url = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
349 if (!url.isEmpty()) {
350 startDownload(url);
351 return;
352 }
353
354 // Save downloaded data to disk
355 QFile file(m_downloadDir.filePath(m_fileName + PARTIAL_DOWN));
356 if (file.open(QIODevice::WriteOnly | QIODevice::Append)) {
357 file.write(m_reply->readAll());
358 file.close();
359 }
360}
361
362/**
363 * @brief Calculates the appropriate size units (bytes, KB or MB) for the

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.80
filePathMethod · 0.45
openMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected