Skip to content
Browse files
dbhub: Send last modified date when pushing database
Also add some code for receiving the last modified data when fetching
but we're not yet able to set it.
  • Loading branch information
MKleusberg committed Sep 30, 2017
1 parent f926a67 commit 8c0e4bfdaaef17d93c888d3f97e5e9383fcd7bd5
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/RemoteDatabase.cpp
@@ -12,6 +12,7 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QHttpMultiPart>
#include <QTimeZone>

#include "RemoteDatabase.h"
#include "version.h"
@@ -150,6 +151,17 @@ void RemoteDatabase::gotReply(QNetworkReply* reply)

// Set last modified data of the new file to the one provided by the server
// TODO Qt doesn't offer any option to set this attribute, so we'd need to figure out a way to do it
// ourselves in a platform-independent way.
/*QString last_modified = reply->rawHeader("Content-Disposition");
QRegExp regex("^.*modification-date=\"(.+)\";.*$");
regex.setMinimal(true); // Set to non-greedy matching
if(regex.indexIn(last_modified) != -1)
last_modified = regex.cap(1);

// Tell the application to open this file
emit openFile(saveFileAs);
@@ -437,6 +449,11 @@ void RemoteDatabase::push(const QString& filename, const QString& url, const QSt
request.setRawHeader("User-Agent", QString("%1 %2").arg(qApp->organizationName()).arg(APP_VERSION).toUtf8());

// Get the last modified date of the file and prepare it for conversion into the ISO date format
QDateTime last_modified = QFileInfo(filename).lastModified();

// Prepare HTTP multi part data containing all the information about the commit we're about to push
QHttpMultiPart* multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
addPart(multipart, "file", file, remotename);
@@ -446,6 +463,7 @@ void RemoteDatabase::push(const QString& filename, const QString& url, const QSt
addPart(multipart, "branch", branch);
addPart(multipart, "commit", localLastCommitId(filename));
addPart(multipart, "force", forcePush ? "true" : "false");
addPart(multipart, "lastmodified", last_modified.toString(Qt::ISODate));

// Set SSL configuration when trying to access a file via the HTTPS protocol
bool https = QUrl(url).scheme().compare("https", Qt::CaseInsensitive) == 0;

0 comments on commit 8c0e4bf

Please sign in to comment.