mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 03:37:47 +00:00
Add a way to manually overwrite what's on the server
In the case where you accidentally uploaded the wrong data, or your data is hosed to begin with.
This commit is contained in:
parent
807cf0e062
commit
5ac2002bcb
4 changed files with 44 additions and 3 deletions
|
@ -19,6 +19,7 @@ class SyncManager : public QObject
|
|||
Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
|
||||
Q_PROPERTY(QString userId READ userId NOTIFY userIdChanged)
|
||||
Q_PROPERTY(Quotient::Connection *connection READ connection NOTIFY connectionChanged)
|
||||
Q_PROPERTY(bool initialSync READ initialSync WRITE setInitialSync NOTIFY initialSyncChanged)
|
||||
|
||||
public:
|
||||
explicit SyncManager(QObject *parent = nullptr);
|
||||
|
@ -97,12 +98,19 @@ public:
|
|||
*/
|
||||
QCoro::Task<> breakLock();
|
||||
|
||||
/**
|
||||
* @return If we should always update data on the server, and don't care about the previous data.
|
||||
*/
|
||||
bool initialSync() const;
|
||||
void setInitialSync(bool initialSync);
|
||||
|
||||
Q_SIGNALS:
|
||||
void connectedChanged();
|
||||
void userIdChanged();
|
||||
void connectionChanged();
|
||||
void isReadyChanged();
|
||||
void loginError(const QString &message);
|
||||
void initialSyncChanged();
|
||||
|
||||
private:
|
||||
void invokeLogin();
|
||||
|
@ -113,4 +121,5 @@ private:
|
|||
Quotient::AccountRegistry m_accountRegistry;
|
||||
|
||||
Quotient::Room *m_currentRoom = nullptr;
|
||||
bool m_initialSync = false;
|
||||
};
|
||||
|
|
|
@ -77,6 +77,11 @@ QCoro::Task<bool> CharacterSync::sync(const bool initialSync)
|
|||
|
||||
qCDebug(ASTRA_LOG) << "Character directories:" << characterDirs;
|
||||
|
||||
const bool manualOverwrite = syncManager->initialSync();
|
||||
|
||||
// Reset initial sync setting
|
||||
syncManager->setInitialSync(false);
|
||||
|
||||
for (const auto &dir : characterDirs) {
|
||||
const QString id = dir.fileName(); // FFXIV_CHR0040000001000001 for example
|
||||
const auto previousData = co_await syncManager->getUploadedCharacterData(id);
|
||||
|
@ -104,7 +109,7 @@ QCoro::Task<bool> CharacterSync::sync(const bool initialSync)
|
|||
const bool isGameClosing = !initialSync;
|
||||
|
||||
// We want to upload if the files are truly different, or there is no existing data on the server.
|
||||
const bool needsUpload = (areFilesDifferent && isGameClosing) || hasPreviousUpload;
|
||||
const bool needsUpload = (areFilesDifferent && isGameClosing) || hasPreviousUpload || manualOverwrite;
|
||||
|
||||
// We want to download if the files are different.
|
||||
const bool needsDownload = areFilesDifferent;
|
||||
|
@ -116,7 +121,7 @@ QCoro::Task<bool> CharacterSync::sync(const bool initialSync)
|
|||
} else if (needsDownload) {
|
||||
qCDebug(ASTRA_LOG) << id << "downloading character data";
|
||||
if (!co_await downloadCharacterData(dir.absoluteFilePath(), id, previousData->mxcUri)) {
|
||||
Q_EMIT launcher.loginError(i18n("Failed to sync character data from the server. Please do another initial sync under Settings and try again."));
|
||||
Q_EMIT launcher.loginError(i18n("Failed to sync character data from the server. You can try overwriting existing data under Settings."));
|
||||
co_return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -322,4 +322,17 @@ QCoro::Task<> SyncManager::breakLock()
|
|||
co_return;
|
||||
}
|
||||
|
||||
bool SyncManager::initialSync() const
|
||||
{
|
||||
return m_initialSync;
|
||||
}
|
||||
|
||||
void SyncManager::setInitialSync(bool initialSync)
|
||||
{
|
||||
if (m_initialSync != initialSync) {
|
||||
m_initialSync = initialSync;
|
||||
Q_EMIT initialSyncChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_syncmanager.cpp"
|
||||
|
|
|
@ -100,6 +100,20 @@ FormCard.FormCardPage {
|
|||
|
||||
FormCard.FormDelegateSeparator {
|
||||
above: usernameLabelDelegate
|
||||
below: initialSyncDelegate
|
||||
}
|
||||
|
||||
FormCard.FormCheckDelegate {
|
||||
id: initialSyncDelegate
|
||||
|
||||
text: i18n("Overwrite existing data")
|
||||
description: i18n("Temporarily overwrite any existing data on the server. This setting is not saved, and is reset when you log in.")
|
||||
checked: LauncherCore.syncManager.initialSync
|
||||
onCheckedChanged: LauncherCore.syncManager.initialSync = checked
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator {
|
||||
above: initialSyncDelegate
|
||||
below: logoutDelegate
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue