mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-05-29 21:02:26 -04:00
create the directory if one is supplied that doesn't exist
This commit is contained in:
parent
88b1e46ee4
commit
a7413ae627
@ -7,7 +7,7 @@
|
|||||||
#include <QtNetwork/QNetworkReply>
|
#include <QtNetwork/QNetworkReply>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QTemporaryFile>
|
#include <QIODevice>
|
||||||
#include "qt_helpers.hpp"
|
#include "qt_helpers.hpp"
|
||||||
#include "Logger.hpp"
|
#include "Logger.hpp"
|
||||||
|
|
||||||
@ -187,12 +187,21 @@ void FileDownload::download(QUrl qurl)
|
|||||||
|
|
||||||
QFileInfo destination_file(destination_filename_);
|
QFileInfo destination_file(destination_filename_);
|
||||||
QString const tmpfile_base = destination_file.fileName();
|
QString const tmpfile_base = destination_file.fileName();
|
||||||
QString const tmpfile_path = destination_file.absolutePath();
|
QString const &tmpfile_path = destination_file.absolutePath();
|
||||||
destfile_.setFileName(destination_file.absoluteFilePath());
|
QDir tmpdir{};
|
||||||
if (!destfile_.open(QSaveFile::WriteOnly))
|
if (!tmpdir.mkpath(tmpfile_path))
|
||||||
{
|
{
|
||||||
LOG_INFO(QString{"FileDownload [%1]: Unable to open the temporary file based on %2"}.arg(user_agent_).arg(tmpfile_path));
|
LOG_INFO(QString{"FileDownload [%1]: Directory %2 does not exist"}.arg(user_agent_).arg(tmpfile_path).arg(
|
||||||
return;
|
destfile_.errorString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url_valid_) {
|
||||||
|
destfile_.setFileName(destination_file.absoluteFilePath());
|
||||||
|
if (!destfile_.open(QSaveFile::WriteOnly | QIODevice::WriteOnly)) {
|
||||||
|
LOG_INFO(QString{"FileDownload [%1]: Unable to open %2: %3"}.arg(user_agent_).arg(destfile_.fileName()).arg(
|
||||||
|
destfile_.errorString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user