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

Remove version checks for < 10 #9676

Merged
merged 2 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions changelog/unreleased/9578
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Change: We removed support for ownCloud servers < 10.0

https://github.com/owncloud/client/issues/9578
3 changes: 2 additions & 1 deletion src/cmd/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ int main(int argc, char **argv)
auto caps = capabilitiesJob->data().value("ocs").toObject().value("data").toObject().value("capabilities").toObject();
qDebug() << "Server capabilities" << caps;
ctx.account->setCapabilities(caps.toVariantMap());
ctx.account->setServerVersion(caps["core"].toObject()["status"].toObject()["version"].toString());
ctx.account->setServerInfo(caps["core"].toObject()["status"].toObject()["version"].toString(),
caps["core"].toObject()["status"].toObject()["productname"].toString());

if (capabilitiesJob->reply()->error() != QNetworkReply::NoError) {
qFatal("Error connecting to server");
Expand Down
2 changes: 1 addition & 1 deletion src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ void AccountSettings::slotAccountStateChanged()
case AccountState::Connected: {
QStringList errors;
if (account->serverVersionUnsupported()) {
errors << tr("The server version %1 is unsupported! Proceed at your own risk.").arg(account->serverVersion());
errors << tr("The server version %1 is unsupported! Proceed at your own risk.").arg(account->serverVersionString());
}
showConnectionLabel(tr("Connected to %1.").arg(serverWithUser), errors);
ui->openBrowserButton->setVisible(false);
Expand Down
22 changes: 12 additions & 10 deletions src/gui/connectionvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@ void ConnectionValidator::slotStatusFound(const QUrl &url, const QJsonObject &in
// Newer servers don't disclose any version in status.php anymore
// https://github.com/owncloud/core/pull/27473/files
// so this string can be empty.
QString serverVersion = info.value(QLatin1String("version")).toString() + QLatin1Char('-') + info.value(QLatin1String("productname")).toString();
const QString serverVersion = info.value(QLatin1String("version")).toString();
const QString serverProduct = info.value(QLatin1String("productname")).toString();

// status.php was found.
qCInfo(lcConnectionValidator) << "** Application: ownCloud found: "
<< url << " with version "
<< info.value(QLatin1String("versionstring")).toString()
<< "(" << serverVersion << ")";
<< "(" << serverVersion << "-" << serverProduct
<< ")";

// Update server url in case of redirection
if (_account->url() != url) {
Expand All @@ -171,7 +173,7 @@ void ConnectionValidator::slotStatusFound(const QUrl &url, const QJsonObject &in
return;
}

if (!serverVersion.isEmpty() && !setAndCheckServerVersion(serverVersion)) {
if (!serverVersion.isEmpty() && !setAndCheckServerInfo(serverVersion, serverProduct)) {
return;
}

Expand Down Expand Up @@ -265,8 +267,9 @@ void ConnectionValidator::checkServerCapabilities()
_account->setCapabilities(caps.toVariantMap());

// New servers also report the version in the capabilities
QString serverVersion = caps["core"].toObject()["status"].toObject()["version"].toString();
if (!serverVersion.isEmpty() && !setAndCheckServerVersion(serverVersion)) {
const QString serverVersion = caps["core"].toObject()["status"].toObject()["version"].toString();
const QString product = caps["core"].toObject()["status"].toObject()["productname"].toString();
if (!setAndCheckServerInfo(serverVersion, product)) {
return;
}

Expand Down Expand Up @@ -312,13 +315,12 @@ void ConnectionValidator::fetchUser()
job->start();
}

bool ConnectionValidator::setAndCheckServerVersion(const QString &version)
bool ConnectionValidator::setAndCheckServerInfo(const QString &version, const QString &serverProduct)
{
_account->setServerVersion(version);
_account->setServerInfo(version, serverProduct);

// We cannot deal with servers < 7.0.0
if (_account->serverVersionInt()
&& _account->serverVersionInt() < Account::makeServerVersion(7, 0, 0)) {
// We cannot deal with servers < 10.0.0
if (_account->serverVersionUnsupported()) {
_errors.append(tr("The configured server for this client is too old"));
_errors.append(tr("Please update to the latest server and restart the client."));
reportResult(ServerVersionMismatch);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/connectionvalidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected slots:
*
* Returns false and reports ServerVersionMismatch for very old servers.
*/
bool setAndCheckServerVersion(const QString &version);
bool setAndCheckServerInfo(const QString &version, const QString &serverProduct);

QStringList _errors;
AccountPtr _account;
Expand Down
15 changes: 1 addition & 14 deletions src/gui/creds/httpcredentialsgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,10 @@ void HttpCredentialsGui::showDialog()

QString HttpCredentialsGui::requestAppPasswordText(const Account *account)
{
int version = account->serverVersionInt();
QString path;

// Version may not be available before login on new servers!
if (!version || version >= Account::makeServerVersion(10, 0, 0)) {
path = QLatin1String("/index.php/settings/personal?sectionid=security#apppasswords");
} else if (version >= Account::makeServerVersion(9, 1, 0)) {
path = QLatin1String("/index.php/settings/personal?section=apppasswords");
} else {
// Older server than 9.1 does not have the feature to request App Password
return QString();
}

auto baseUrl = account->url().toString();
if (baseUrl.endsWith('/'))
baseUrl.chop(1);
return tr("<a href=\"%1\">Click here</a> to request an app password from the web interface.")
.arg(baseUrl + path);
.arg(Utility::concatUrlPath(baseUrl, QStringLiteral("/index.php/settings/personal?sectionid=security#apppasswords")).toString());
}
} // namespace OCC
2 changes: 1 addition & 1 deletion src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void ownCloudGui::slotTrayMessageIfServerUnsupported(Account *account)
tr("The server on account %1 runs an unsupported version %2. "
"Using this client with unsupported server versions is untested and "
"potentially dangerous. Proceed at your own risk.")
.arg(account->displayName(), account->serverVersion()));
.arg(account->displayName(), account->serverVersionString()));
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/gui/sharedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,7 @@ void ShareDialog::showSharingUi()
return;
}

// We only do user/group sharing from 8.2.0
bool userGroupSharing =
theme->userGroupSharing()
&& _accountState->account()->serverVersionInt() >= Account::makeServerVersion(8, 2, 0);

if (userGroupSharing) {
if (theme->userGroupSharing()) {
_userGroupWidget = new ShareUserGroupWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _privateLinkUrl, this);
_ui->shareWidgets->addTab(_userGroupWidget, tr("Users and Groups"));
_userGroupWidget->getShares();
Expand Down
3 changes: 1 addition & 2 deletions src/gui/sharelinkwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ void ShareLinkWidget::getShares()

void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
{
const QString versionString = _account->serverVersion();
qCInfo(lcSharing) << versionString << "Fetched" << shares.count() << "shares";
qCInfo(lcSharing) << "Fetched" << shares.count() << "shares";

// Select the share that was previously selected,
// except if an explicit override was asked for
Expand Down
7 changes: 1 addition & 6 deletions src/gui/sharemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,9 @@ QSharedPointer<LinkShare> ShareManager::parseLinkShare(const QJsonObject &data)
// From ownCloud server 8.2 the url field is always set for public shares
if (data.contains("url")) {
url = QUrl(data.value("url").toString());
} else if (_account->serverVersionInt() >= Account::makeServerVersion(8, 0, 0)) {
} else {
// From ownCloud server version 8 on, a different share link scheme is used.
url = QUrl(Utility::concatUrlPath(_account->url(), QLatin1String("index.php/s/") + data.value("token").toString())).toString();
} else {
QUrlQuery queryArgs;
queryArgs.addQueryItem(QLatin1String("service"), QLatin1String("files"));
queryArgs.addQueryItem(QLatin1String("t"), data.value("token").toString());
url = QUrl(Utility::concatUrlPath(_account->url(), QLatin1String("public.php"), queryArgs).toString());
}

QDate expireDate;
Expand Down
27 changes: 2 additions & 25 deletions src/gui/shareusergroupwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,20 +294,8 @@ void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex &index)
* https://github.com/owncloud/client/issues/4996
*/
const SharePermissions defaultPermissions = static_cast<SharePermissions>(_account->capabilities().defaultPermissions());
if (sharee->type() == Sharee::Federated
&& _account->serverVersionInt() < Account::makeServerVersion(9, 1, 0)) {
SharePermissions permissions = SharePermissionRead | SharePermissionUpdate;
if (!_isFile) {
permissions |= SharePermissionCreate | SharePermissionDelete;
}
permissions &= defaultPermissions;
_manager->createShare(_sharePath, Share::ShareType(sharee->type()),
sharee->shareWith(), permissions);
} else {
_manager->createShare(_sharePath, Share::ShareType(sharee->type()),
sharee->shareWith(), _maxSharingPermissions & defaultPermissions);
}

_manager->createShare(_sharePath, Share::ShareType(sharee->type()),
sharee->shareWith(), _maxSharingPermissions & defaultPermissions);
_ui->shareeLineEdit->setEnabled(false);
_ui->shareeLineEdit->setText(QString());
}
Expand Down Expand Up @@ -405,17 +393,6 @@ ShareUserLine::ShareUserLine(QSharedPointer<Share> share,
connect(_ui->permissionShare, &QAbstractButton::clicked, this, &ShareUserLine::slotPermissionsChanged);
connect(_ui->permissionsEdit, &QAbstractButton::clicked, this, &ShareUserLine::slotEditPermissionsChanged);

/*
* We don't show permssion share for federated shares with server <9.1
* https://github.com/owncloud/core/issues/22122#issuecomment-185637344
* https://github.com/owncloud/client/issues/4996
*/
if (share->getShareType() == Share::TypeRemote
&& share->account()->serverVersionInt() < Account::makeServerVersion(9, 1, 0)) {
_ui->permissionShare->setVisible(false);
_ui->permissionToolButton->setVisible(false);
}

connect(share.data(), &Share::permissionsSet, this, &ShareUserLine::slotPermissionsSet);
connect(share.data(), &Share::shareDeleted, this, &ShareUserLine::slotShareDeleted);

Expand Down
2 changes: 1 addition & 1 deletion src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ void SocketApi::processShareRequest(const QString &localFile, SocketListener *li
const QString message = QLatin1String("SHARE:NOTCONNECTED:") + QDir::toNativeSeparators(localFile);
// if the folder isn't connected, don't open the share dialog
listener->sendMessage(message);
} else if (!theme->linkSharing() && (!theme->userGroupSharing() || shareFolder->accountState()->account()->serverVersionInt() < Account::makeServerVersion(8, 2, 0))) {
} else if (!theme->linkSharing() && !theme->userGroupSharing()) {
const QString message = QLatin1String("SHARE:NOP:") + QDir::toNativeSeparators(localFile);
listener->sendMessage(message);
} else {
Expand Down
40 changes: 24 additions & 16 deletions src/libsync/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,37 +293,45 @@ void Account::setCapabilities(const Capabilities &caps)
_capabilities = caps;
}

QString Account::serverVersion() const
QString Account::serverProductName() const
{
return _serverVersion;
}

int Account::serverVersionInt() const
{
// FIXME: Use Qt 5.5 QVersionNumber
auto components = serverVersion().split(QLatin1Char('.'));
return makeServerVersion(components.value(0).toInt(),
components.value(1).toInt(),
components.value(2).toInt());
return _serverProduct;
}

int Account::makeServerVersion(int majorVersion, int minorVersion, int patchVersion)
QString Account::serverVersionString() const
{
return (majorVersion << 16) + (minorVersion << 8) + patchVersion;
return _serverVersion;
}

bool Account::serverVersionUnsupported() const
{
if (serverVersionInt() == 0) {
if (serverVersion().isNull()) {
// not detected yet, assume it is fine.
return false;
}
// TODO: this is a work around for a ocis announcing version 2.0.0
// next version will announce ocisvison and keep version to 10
if (serverProductName() == QLatin1String("Infinite Scale")) {
return false;
fmoc marked this conversation as resolved.
Show resolved Hide resolved
}
// Older version which is not "end of life" according to https://github.com/owncloud/core/wiki/Maintenance-and-Release-Schedule
return serverVersionInt() < makeServerVersion(10, 0, 0) || serverVersion().endsWith(QLatin1String("Nextcloud"));
if (serverVersion() < QVersionNumber(10)) {
return true;
}
if (serverProductName().endsWith(QLatin1String("Nextcloud"))) {
return true;
}
return false;
}

QVersionNumber Account::serverVersion() const
{
return QVersionNumber::fromString(_serverVersion);
}

void Account::setServerVersion(const QString &version)
void Account::setServerInfo(const QString &version, const QString &productName)
{
_serverProduct = productName;
if (version == _serverVersion) {
return;
}
Expand Down
16 changes: 6 additions & 10 deletions src/libsync/account.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,18 @@ class OWNCLOUDSYNC_EXPORT Account : public QObject

bool hasCapabilities() const;


/** Access the server version
*
* For servers >= 10.0.0, this can be the empty string until capabilities
* have been received.
*/
QString serverVersion() const;
QString serverVersionString() const;
QVersionNumber serverVersion() const;

/** Server version for easy comparison.
*
* Example: serverVersionInt() >= makeServerVersion(11, 2, 3)
*
* Will be 0 if the version is not available yet.
*/
int serverVersionInt() const;
QString serverProductName() const;

static int makeServerVersion(int majorVersion, int minorVersion, int patchVersion);
void setServerVersion(const QString &version);
void setServerInfo(const QString &version, const QString &product);

/** Whether the server is too old.
*
Expand Down Expand Up @@ -261,6 +256,7 @@ protected Q_SLOTS:
QSet<QSslCertificate> _approvedCerts;
Capabilities _capabilities;
QString _serverVersion;
QString _serverProduct;
QuotaInfo *_quotaInfo;
QPointer<AccessManager> _am;
QScopedPointer<AbstractCredentials> _credentials;
Expand Down
28 changes: 14 additions & 14 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,23 +350,23 @@ void DiscoverySingleDirectoryJob::start()
// Start the actual HTTP job
LsColJob *lsColJob = new LsColJob(_account, _baseUrl, _subPath, this);

QList<QByteArray> props;
props << "resourcetype"
<< "getlastmodified"
<< "getcontentlength"
<< "getetag"
<< "http://owncloud.org/ns:id"
<< "http://owncloud.org/ns:downloadURL"
<< "http://owncloud.org/ns:dDC"
<< "http://owncloud.org/ns:permissions"
<< "http://owncloud.org/ns:checksums";
if (_isRootPath)
QList<QByteArray> props {
"resourcetype",
"getlastmodified",
"getcontentlength",
"getetag",
"http://owncloud.org/ns:id",
"http://owncloud.org/ns:downloadURL",
"http://owncloud.org/ns:dDC",
"http://owncloud.org/ns:permissions",
"http://owncloud.org/ns:checksums",
"http://owncloud.org/ns:share-types"
};
if (_isRootPath) {
props << "http://owncloud.org/ns:data-fingerprint";
if (_account->serverVersionInt() >= Account::makeServerVersion(10, 0, 0)) {
// Server older than 10.0 have performances issue if we ask for the share-types on every PROPFIND
props << "http://owncloud.org/ns:share-types";
}


lsColJob->setProperties(props);

QObject::connect(lsColJob, &LsColJob::directoryListingIterated,
Expand Down
17 changes: 7 additions & 10 deletions src/libsync/propagateuploadv1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,14 @@ void PropagateUploadFileV1::startNextChunk()
// Server may also disable parallel chunked upload for any higher version
parallelChunkUpload = false;
} else {
QByteArray env = qgetenv("OWNCLOUD_PARALLEL_CHUNK");
if (!env.isEmpty()) {
parallelChunkUpload = env != "false" && env != "0";
} else {
int versionNum = propagator()->account()->serverVersionInt();
if (versionNum < Account::makeServerVersion(8, 0, 3)) {
// Disable parallel chunk upload severs older than 8.0.3 to avoid too many
// internal sever errors (#2743, #2938)
parallelChunkUpload = false;
static bool envEnabled = [] {
const auto env = qEnvironmentVariable("OWNCLOUD_PARALLEL_CHUNK");
if (!env.isEmpty()) {
return env != QLatin1String("false") && env != QLatin1String("0");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe allow any arbitrary casing of the value by comparing to a lowercase value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The env var is not even documented and its behavior is orthogonal to all other env checks.
Unrelated to the review

}
}
return true;
}();
parallelChunkUpload = envEnabled;
}


Expand Down
6 changes: 1 addition & 5 deletions test/testutils/syncenginetestutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,12 +941,8 @@ FakeFolder::FakeFolder(const FileInfo &fileTemplate, OCC::Vfs::Mode vfsMode)
toDisk(rootDir, fileTemplate);

_fakeAm = new FakeAM(fileTemplate);
_account = OCC::Account::create();
_account->setUrl(QUrl(QStringLiteral("http://admin:admin@localhost/owncloud")));
_account = OCC::TestUtils::createDummyAccount();
_account->setCredentials(new FakeCredentials { _fakeAm });
_account->setDavDisplayName(QStringLiteral("fakename"));
_account->setServerVersion(QStringLiteral("10.0.0"));
_account->setCapabilities(OCC::TestUtils::testCapabilities());

_journalDb.reset(new OCC::SyncJournalDb(localPath() + QStringLiteral(".sync_test.db")));
// TODO: davUrl
Expand Down
Loading