Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include mtime in tus Upload-Metadata #10958

Merged
merged 1 commit into from
Jun 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/libsync/propagateuploadtus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,19 @@ UploadDevice *PropagateUploadFileTUS::prepareDevice(const quint64 &chunkSize)
SimpleNetworkJob *PropagateUploadFileTUS::makeCreationWithUploadJob(QNetworkRequest *request, UploadDevice *device)
{
Q_ASSERT(propagator()->account()->capabilities().tusSupport().extensions.contains(QStringLiteral("creation-with-upload")));
// in difference to the old protocol the algrithm and the value are space seperated

const auto checksumHeader = ChecksumHeader::parseChecksumHeader(_transmissionChecksumHeader);
const QByteArray checkSum = QByteArray(CheckSums::toQString(checksumHeader.type()).toUtf8() + ' ' + checksumHeader.checksum()).toBase64();
const QByteArray base64Path = propagator()->fullRemotePath(_item->_file).toUtf8().toBase64();
qCDebug(lcPropagateUploadTUS) << "FullPath:" << propagator()->fullRemotePath(_item->_file) << "Base64:" << base64Path;
request->setRawHeader(QByteArrayLiteral("Upload-Metadata"), "filename " + base64Path + ",checksum " + checkSum);

QByteArrayList encodedMetaData;
auto addMetaData = [&encodedMetaData](const QByteArray &key, const QByteArray &value) { encodedMetaData << key + ' ' + value.toBase64(); };
erikjv marked this conversation as resolved.
Show resolved Hide resolved
addMetaData(QByteArrayLiteral("filename"), propagator()->fullRemotePath(_item->_file).toUtf8());
// in difference to the old protocol the algrithm and the value are space seperated
addMetaData(QByteArrayLiteral("checksum"), CheckSums::toQString(checksumHeader.type()).toUtf8() + ' ' + checksumHeader.checksum());
addMetaData(QByteArrayLiteral("mtime"), QByteArray::number(_item->_modtime));

request->setRawHeader(QByteArrayLiteral("Upload-Metadata"), encodedMetaData.join(','));
request->setRawHeader(QByteArrayLiteral("Upload-Length"), QByteArray::number(_item->_size));
auto job = new SimpleNetworkJob(propagator()->account(), propagator()->webDavUrl(), {}, "POST", device, *request, this);
return job;
return new SimpleNetworkJob(propagator()->account(), propagator()->webDavUrl(), {}, "POST", device, *request, this);
}

QNetworkRequest PropagateUploadFileTUS::prepareRequest(const quint64 &chunkSize)
Expand Down