Skip to content

Commit 044738b

Browse files
committed
store the public share link url instead of sync URL for public share
fix save/load cycle when we restart client with public share links Signed-off-by: Matthieu Gallien <[email protected]>
1 parent f4c348f commit 044738b

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/gui/accountmanager.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,11 @@ void AccountManager::saveAccountState(AccountState *a)
220220
void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool saveCredentials)
221221
{
222222
settings.setValue(QLatin1String(versionC), maxAccountVersion);
223-
settings.setValue(QLatin1String(urlC), acc->_url.toString());
223+
if (acc->isPublicShareLink()) {
224+
settings.setValue(QLatin1String(urlC), acc->publicShareLinkUrl().toString());
225+
} else {
226+
settings.setValue(QLatin1String(urlC), acc->_url.toString());
227+
}
224228
settings.setValue(QLatin1String(davUserC), acc->_davUser);
225229
settings.setValue(QLatin1String(serverVersionC), acc->_serverVersion);
226230
if (acc->_credentials) {

src/libsync/account.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,24 @@ void Account::setUrl(const QUrl &url)
443443
_url.setUserName(isPublicLink.captured(2));
444444
setDavUser(isPublicLink.captured(2));
445445
_isPublicLink = true;
446+
_publicShareLinkUrl = url;
446447
} else {
447448
_url = url;
448449
}
449450

450451
_userVisibleUrl = url;
451452
}
452453

454+
QUrl Account::url() const
455+
{
456+
return _url;
457+
}
458+
459+
QUrl Account::publicShareLinkUrl() const
460+
{
461+
return _publicShareLinkUrl;
462+
}
463+
453464
void Account::setUserVisibleHost(const QString &host)
454465
{
455466
_userVisibleUrl.setHost(host);

src/libsync/account.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject
114114

115115
/** Server url of the account */
116116
void setUrl(const QUrl &url);
117-
QUrl url() const { return _url; }
117+
QUrl url() const;
118+
QUrl publicShareLinkUrl() const;
118119

119120
bool isPublicShareLink() const
120121
{
@@ -331,6 +332,7 @@ protected Q_SLOTS:
331332
#endif
332333
QMap<QString, QVariant> _settingsMap;
333334
QUrl _url;
335+
QUrl _publicShareLinkUrl;
334336
bool _isPublicLink = false;
335337

336338
/** If url to use for any user-visible urls.

0 commit comments

Comments
 (0)