Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[buteo-sync-plugins-social] Add device display name to backup file na…
…mes. Contributes to JB#33704
  • Loading branch information
Bea Lam committed May 12, 2016
1 parent 80af44e commit 8781bd8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/dropbox/dropbox-backup/dropboxbackupsyncadaptor.cpp
Expand Up @@ -71,7 +71,8 @@ void DropboxBackupSyncAdaptor::purgeDataForOldAccount(int oldId, SocialNetworkSy

void DropboxBackupSyncAdaptor::beginSync(int accountId, const QString &accessToken)
{
QString deviceId = SsuDeviceInfo().deviceUid();
SsuDeviceInfo deviceInfo;
QString deviceId = deviceInfo.deviceUid();
QByteArray hashedDeviceId = QCryptographicHash::hash(deviceId.toUtf8(), QCryptographicHash::Sha256);
QString encodedDeviceId = QString::fromUtf8(hashedDeviceId.toBase64()).mid(0,12);
if (deviceId.isEmpty()) {
Expand All @@ -80,7 +81,11 @@ void DropboxBackupSyncAdaptor::beginSync(int accountId, const QString &accessTok
return;
}

QString defaultRemotePath = QString::fromLatin1("Backups/%1").arg(encodedDeviceId);
QString deviceDisplayNamePrefix = deviceInfo.displayName(Ssu::DeviceModel);
if (!deviceDisplayNamePrefix.isEmpty()) {
deviceDisplayNamePrefix = deviceDisplayNamePrefix.replace(' ', '-') + '_';
}
QString defaultRemotePath = QString::fromLatin1("Backups/%1%2").arg(deviceDisplayNamePrefix).arg(encodedDeviceId);
QString defaultLocalPath = QString::fromLatin1("%1/Backups/")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR));

Expand Down
9 changes: 7 additions & 2 deletions src/onedrive/onedrive-backup/onedrivebackupsyncadaptor.cpp
Expand Up @@ -105,7 +105,8 @@ void OneDriveBackupSyncAdaptor::purgeDataForOldAccount(int oldId, SocialNetworkS

void OneDriveBackupSyncAdaptor::beginSync(int accountId, const QString &accessToken)
{
QString deviceId = SsuDeviceInfo().deviceUid();
SsuDeviceInfo deviceInfo;
QString deviceId = deviceInfo.deviceUid();
QByteArray hashedDeviceId = QCryptographicHash::hash(deviceId.toUtf8(), QCryptographicHash::Sha256);
QString encodedDeviceId = QString::fromUtf8(hashedDeviceId.toBase64()).mid(0,12);
if (deviceId.isEmpty()) {
Expand All @@ -114,7 +115,11 @@ void OneDriveBackupSyncAdaptor::beginSync(int accountId, const QString &accessTo
return;
}

QString defaultRemotePath = QString::fromLatin1("Backups/%1").arg(encodedDeviceId);
QString deviceDisplayNamePrefix = deviceInfo.displayName(Ssu::DeviceModel);
if (!deviceDisplayNamePrefix.isEmpty()) {
deviceDisplayNamePrefix = deviceDisplayNamePrefix.replace(' ', '-') + '_';
}
QString defaultRemotePath = QString::fromLatin1("Backups/%1%2").arg(deviceDisplayNamePrefix).arg(encodedDeviceId);
QString defaultLocalPath = QString::fromLatin1("%1/Backups/")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR));

Expand Down

0 comments on commit 8781bd8

Please sign in to comment.