mirror of
https://github.com/overte-org/overte.git
synced 2025-04-13 16:05:17 +02:00
Update backup downloads to use .content.zip extension
This commit is contained in:
parent
6552aeac4d
commit
9275fe1f7d
1 changed files with 9 additions and 2 deletions
|
@ -20,6 +20,7 @@
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
|
@ -2133,9 +2134,10 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
_contentManager->getAllBackupsAndStatus(deferred);
|
_contentManager->getAllBackupsAndStatus(deferred);
|
||||||
return true;
|
return true;
|
||||||
} else if (url.path().startsWith(URI_API_BACKUPS_ID)) {
|
} else if (url.path().startsWith(URI_API_BACKUPS_ID)) {
|
||||||
|
constexpr const char* CONTENT_TYPE_ZIP = "application/zip";
|
||||||
auto id = url.path().mid(QString(URI_API_BACKUPS_ID).length());
|
auto id = url.path().mid(QString(URI_API_BACKUPS_ID).length());
|
||||||
auto deferred = makePromise("consolidateBackup");
|
auto deferred = makePromise("consolidateBackup");
|
||||||
deferred->then([connectionPtr, JSON_MIME_TYPE](QString error, QVariantMap result) {
|
deferred->then([connectionPtr, JSON_MIME_TYPE, id](QString error, QVariantMap result) {
|
||||||
if (!connectionPtr) {
|
if (!connectionPtr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2146,7 +2148,12 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
auto path = result["backupFilePath"].toString();
|
auto path = result["backupFilePath"].toString();
|
||||||
auto file { std::unique_ptr<QFile>(new QFile(path)) };
|
auto file { std::unique_ptr<QFile>(new QFile(path)) };
|
||||||
if (file->open(QIODevice::ReadOnly)) {
|
if (file->open(QIODevice::ReadOnly)) {
|
||||||
connectionPtr->respond(HTTPConnection::StatusCode200, std::move(file));
|
auto downloadedFilename = id;
|
||||||
|
downloadedFilename.replace(QRegularExpression(".zip$"), ".content.zip");
|
||||||
|
auto contentDisposition = "attachment; filename=\"" + downloadedFilename + "\"";
|
||||||
|
connectionPtr->respond(HTTPConnection::StatusCode200, std::move(file), CONTENT_TYPE_ZIP, {
|
||||||
|
{ "Content-Disposition", contentDisposition.toUtf8() }
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
qCritical(domain_server) << "Unable to load consolidated backup at:" << path << result;
|
qCritical(domain_server) << "Unable to load consolidated backup at:" << path << result;
|
||||||
connectionPtr->respond(HTTPConnection::StatusCode500, "Error opening backup");
|
connectionPtr->respond(HTTPConnection::StatusCode500, "Error opening backup");
|
||||||
|
|
Loading…
Reference in a new issue