Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Update OneDrive backups plugin. Contribut…
Browse files Browse the repository at this point in the history
…es to JB#44541
  • Loading branch information
Chris Adams committed Apr 22, 2020
1 parent fb71c24 commit ff693d6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/onedrive/onedrivebackupoperationsyncadaptor.cpp
Expand Up @@ -262,7 +262,7 @@ void OneDriveBackupOperationSyncAdaptor::beginListOperation(int accountId, const
return;
}

QUrl url(QStringLiteral("https://api.onedrive.com/v1.0/drive/special/approot:/%1:/").arg(remoteDirPath));
QUrl url(QStringLiteral("%1/%2:/%3:/").arg(api(), QStringLiteral("drive/special/approot"), remoteDirPath));
QUrlQuery query(url);
QList<QPair<QString, QString> > queryItems;
queryItems.append(QPair<QString, QString>(QStringLiteral("expand"), QStringLiteral("children")));
Expand Down Expand Up @@ -399,7 +399,7 @@ void OneDriveBackupOperationSyncAdaptor::initialiseAppFolderRequest(int accountI
// initialise the app folder and get the remote id of the drive/special/approot path.
// e.g., let's say we have a final path like: drive/special/approot/Backups/ABCDEFG/backup.tar
// this request will get us the id of the drive/special/approot bit.
QUrl url = QUrl(QStringLiteral("https://api.onedrive.com/v1.0/drive/special/approot"));
QUrl url = QUrl(QStringLiteral("%1/%2").arg(api(), QStringLiteral("drive/special/approot")));

QNetworkRequest req(url);
req.setRawHeader(QString(QLatin1String("Authorization")).toUtf8(),
Expand Down Expand Up @@ -494,7 +494,7 @@ void OneDriveBackupOperationSyncAdaptor::getRemoteFolderMetadata(int accountId,
// e.g., let's say we have a final path like: drive/special/approot/Backups/ABCDEFG/backup.tar
// this request will, when first called, be passed the remote id of the drive/special/approot bit
// so we request the metadata for that (expanding children)
QUrl url = QUrl(QStringLiteral("https://api.onedrive.com/v1.0/drive/items/%1").arg(parentId));
QUrl url = QUrl(QStringLiteral("%1/%2/%3").arg(api(), QStringLiteral("drive/items"), parentId));
QUrlQuery query(url);
QList<QPair<QString, QString> > queryItems;
queryItems.append(QPair<QString, QString>(QStringLiteral("expand"), QStringLiteral("children")));
Expand Down Expand Up @@ -622,7 +622,7 @@ void OneDriveBackupOperationSyncAdaptor::requestData(int accountId, const QStrin
// directory or file info request. We use the path and sign with access token.
if (remoteFile.isEmpty()) {
// directory request. expand the children.
url = QUrl(QStringLiteral("https://api.onedrive.com/v1.0/%1:/%2:/").arg(m_remoteAppDir).arg(remotePath));
url = QUrl(QStringLiteral("%1/%2:/%3:/").arg(api(), m_remoteAppDir, remotePath));
QUrlQuery query(url);
QList<QPair<QString, QString> > queryItems;
queryItems.append(QPair<QString, QString>(QStringLiteral("expand"), QStringLiteral("children")));
Expand All @@ -631,7 +631,7 @@ void OneDriveBackupOperationSyncAdaptor::requestData(int accountId, const QStrin
SOCIALD_LOG_DEBUG("performing directory request:" << url.toString());
} else {
// file request, download its metadata. That will contain a content URL which we will redirect to.
url = QUrl(QStringLiteral("https://api.onedrive.com/v1.0/%1:/%2/%3").arg(m_remoteAppDir).arg(remotePath).arg(remoteFile));
url = QUrl(QStringLiteral("%1/%2:/%3/%4").arg(api(), m_remoteAppDir, remotePath, remoteFile));
SOCIALD_LOG_DEBUG("performing file request:" << url.toString());
}
}
Expand Down Expand Up @@ -801,7 +801,7 @@ void OneDriveBackupOperationSyncAdaptor::uploadData(int accountId, const QString
"}").arg(remoteDir);
QByteArray data = createFolderJson.toUtf8();

QUrl url = QUrl(QStringLiteral("https://api.onedrive.com/v1.0/drive/items/%1/children").arg(remoteParentId));
QUrl url = QUrl(QStringLiteral("%1/drive/items/%2/children").arg(api(), remoteParentId));
intermediatePath = QStringLiteral("%1/%2").arg(remoteParentPath).arg(remoteDir);
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentLengthHeader, data.size());
Expand All @@ -815,8 +815,8 @@ void OneDriveBackupOperationSyncAdaptor::uploadData(int accountId, const QString
reply = m_networkAccessManager->post(request, data);
} else {
// attempt to create a remote file.
QUrl url = QUrl(QStringLiteral("https://api.onedrive.com/v1.0/%1:/%2/%3:/content").arg(m_remoteAppDir).arg(remotePath).arg(localFile));
QString localFileName = QStringLiteral("%1/%2").arg(localPath).arg(localFile);
QUrl url = QUrl(QStringLiteral("%1/%2:/%3/%4:/content").arg(api(), m_remoteAppDir, remotePath, localFile));
QString localFileName = QStringLiteral("%1/%2").arg(localPath, localFile);
QFile f(localFileName, this);
if(!f.open(QIODevice::ReadOnly)){
SOCIALD_LOG_ERROR("unable to open local file:" << localFileName << "for upload to OneDrive Backup with account:" << accountId);
Expand Down

0 comments on commit ff693d6

Please sign in to comment.