mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-29 04:08:54 +03:00
Merge pull request #313 from nextcloud/upstream/pr/6380
ConnectionValidator: change the minimum server version
This commit is contained in:
commit
c9634d65aa
7 changed files with 5 additions and 115 deletions
|
@ -276,15 +276,15 @@ bool ConnectionValidator::setAndCheckServerVersion(const QString &version)
|
||||||
qCInfo(lcConnectionValidator) << _account->url() << "has server version" << version;
|
qCInfo(lcConnectionValidator) << _account->url() << "has server version" << version;
|
||||||
_account->setServerVersion(version);
|
_account->setServerVersion(version);
|
||||||
|
|
||||||
// We cannot deal with servers < 5.0.0
|
// We cannot deal with servers < 7.0.0
|
||||||
if (_account->serverVersionInt()
|
if (_account->serverVersionInt()
|
||||||
&& _account->serverVersionInt() < Account::makeServerVersion(5, 0, 0)) {
|
&& _account->serverVersionInt() < Account::makeServerVersion(7, 0, 0)) {
|
||||||
_errors.append(tr("The configured server for this client is too old"));
|
_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."));
|
_errors.append(tr("Please update to the latest server and restart the client."));
|
||||||
reportResult(ServerVersionMismatch);
|
reportResult(ServerVersionMismatch);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// We attempt to work with servers >= 5.0.0 but warn users.
|
// We attempt to work with servers >= 7.0.0 but warn users.
|
||||||
// Check usages of Account::serverVersionUnsupported() for details.
|
// Check usages of Account::serverVersionUnsupported() for details.
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
|
||||||
|
|
|
@ -475,7 +475,7 @@ bool Account::serverVersionUnsupported() const
|
||||||
// not detected yet, assume it is fine.
|
// not detected yet, assume it is fine.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return serverVersionInt() < makeServerVersion(7, 0, 0);
|
return serverVersionInt() < makeServerVersion(9, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::setServerVersion(const QString &version)
|
void Account::setServerVersion(const QString &version)
|
||||||
|
|
|
@ -286,60 +286,6 @@ void PropagateItemJob::done(SyncFileItem::Status statusArg, const QString &error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* For delete or remove, check that we are not removing from a shared directory.
|
|
||||||
* If we are, try to restore the file
|
|
||||||
*
|
|
||||||
* Return true if the problem is handled.
|
|
||||||
*/
|
|
||||||
bool PropagateItemJob::checkForProblemsWithShared(int httpStatusCode, const QString &msg)
|
|
||||||
{
|
|
||||||
PropagateItemJob *newJob = NULL;
|
|
||||||
|
|
||||||
if (httpStatusCode == 403 && propagator()->isInSharedDirectory(_item->_file)) {
|
|
||||||
if (!_item->isDirectory()) {
|
|
||||||
SyncFileItemPtr downloadItem(new SyncFileItem(*_item));
|
|
||||||
if (downloadItem->_instruction == CSYNC_INSTRUCTION_NEW
|
|
||||||
|| downloadItem->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE) {
|
|
||||||
// don't try to recover pushing new files
|
|
||||||
return false;
|
|
||||||
} else if (downloadItem->_instruction == CSYNC_INSTRUCTION_SYNC) {
|
|
||||||
// we modified the file locally, just create a conflict then
|
|
||||||
downloadItem->_instruction = CSYNC_INSTRUCTION_CONFLICT;
|
|
||||||
|
|
||||||
// HACK to avoid continuation: See task #1448: We do not know the _modtime from the
|
|
||||||
// server, at this point, so just set the current one. (rather than the one locally)
|
|
||||||
downloadItem->_modtime = Utility::qDateTimeToTime_t(QDateTime::currentDateTimeUtc());
|
|
||||||
} else {
|
|
||||||
// the file was removed or renamed, just recover the old one
|
|
||||||
downloadItem->_instruction = CSYNC_INSTRUCTION_SYNC;
|
|
||||||
}
|
|
||||||
downloadItem->_direction = SyncFileItem::Down;
|
|
||||||
newJob = new PropagateDownloadFile(propagator(), downloadItem);
|
|
||||||
} else {
|
|
||||||
// Directories are harder to recover.
|
|
||||||
// But just re-create the directory, next sync will be able to recover the files
|
|
||||||
SyncFileItemPtr mkdirItem(new SyncFileItem(*_item));
|
|
||||||
mkdirItem->_instruction = CSYNC_INSTRUCTION_NEW;
|
|
||||||
mkdirItem->_direction = SyncFileItem::Down;
|
|
||||||
newJob = new PropagateLocalMkdir(propagator(), mkdirItem);
|
|
||||||
// Also remove the inodes and fileid from the db so no further renames are tried for
|
|
||||||
// this item.
|
|
||||||
propagator()->_journal->avoidRenamesOnNextSync(_item->_file);
|
|
||||||
propagator()->_anotherSyncNeeded = true;
|
|
||||||
}
|
|
||||||
if (newJob) {
|
|
||||||
newJob->setRestoreJobMsg(msg);
|
|
||||||
_restoreJob.reset(newJob);
|
|
||||||
connect(_restoreJob.data(), &PropagatorJob::finished,
|
|
||||||
this, &PropagateItemJob::slotRestoreJobFinished);
|
|
||||||
QMetaObject::invokeMethod(newJob, "start");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropagateItemJob::slotRestoreJobFinished(SyncFileItem::Status status)
|
void PropagateItemJob::slotRestoreJobFinished(SyncFileItem::Status status)
|
||||||
{
|
{
|
||||||
QString msg;
|
QString msg;
|
||||||
|
@ -559,23 +505,6 @@ void OwncloudPropagator::setSyncOptions(const SyncOptions &syncOptions)
|
||||||
_chunkSize = syncOptions._initialChunkSize;
|
_chunkSize = syncOptions._initialChunkSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ownCloud server < 7.0 did not had permissions so we need some other euristics
|
|
||||||
// to detect wrong doing in a Shared directory
|
|
||||||
bool OwncloudPropagator::isInSharedDirectory(const QString &file)
|
|
||||||
{
|
|
||||||
bool re = false;
|
|
||||||
if (_remoteFolder.startsWith(QLatin1String("Shared"))) {
|
|
||||||
// The Shared directory is synced as its own sync connection
|
|
||||||
re = true;
|
|
||||||
} else {
|
|
||||||
if (file.startsWith("Shared/") || file == "Shared") {
|
|
||||||
// The whole ownCloud is synced and Shared is always a top dir
|
|
||||||
re = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return re;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OwncloudPropagator::localFileNameClash(const QString &relFile)
|
bool OwncloudPropagator::localFileNameClash(const QString &relFile)
|
||||||
{
|
{
|
||||||
bool re = false;
|
bool re = false;
|
||||||
|
|
|
@ -158,8 +158,6 @@ class PropagateItemJob : public PropagatorJob
|
||||||
protected:
|
protected:
|
||||||
void done(SyncFileItem::Status status, const QString &errorString = QString());
|
void done(SyncFileItem::Status status, const QString &errorString = QString());
|
||||||
|
|
||||||
bool checkForProblemsWithShared(int httpStatusCode, const QString &msg);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set a custom restore job message that is used if the restore job succeeded.
|
* set a custom restore job message that is used if the restore job succeeded.
|
||||||
* It is displayed in the activity view.
|
* It is displayed in the activity view.
|
||||||
|
@ -436,8 +434,6 @@ public:
|
||||||
/* The maximum number of active jobs in parallel */
|
/* The maximum number of active jobs in parallel */
|
||||||
int hardMaximumActiveJob();
|
int hardMaximumActiveJob();
|
||||||
|
|
||||||
bool isInSharedDirectory(const QString &file);
|
|
||||||
|
|
||||||
/** Check whether a download would clash with an existing file
|
/** Check whether a download would clash with an existing file
|
||||||
* in filesystems that are only case-preserving.
|
* in filesystems that are only case-preserving.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -111,11 +111,6 @@ void PropagateRemoteDelete::slotDeleteJobFinished()
|
||||||
_item->_httpErrorCode = httpStatus;
|
_item->_httpErrorCode = httpStatus;
|
||||||
|
|
||||||
if (err != QNetworkReply::NoError && err != QNetworkReply::ContentNotFoundError) {
|
if (err != QNetworkReply::NoError && err != QNetworkReply::ContentNotFoundError) {
|
||||||
if (checkForProblemsWithShared(_item->_httpErrorCode,
|
|
||||||
tr("The file has been removed from a read only share. It was restored."))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SyncFileItem::Status status = classifyError(err, _item->_httpErrorCode,
|
SyncFileItem::Status status = classifyError(err, _item->_httpErrorCode,
|
||||||
&propagator()->_anotherSyncNeeded);
|
&propagator()->_anotherSyncNeeded);
|
||||||
done(status, _job->errorString());
|
done(status, _job->errorString());
|
||||||
|
|
|
@ -88,24 +88,6 @@ void PropagateRemoteMove::start()
|
||||||
finalize();
|
finalize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_item->_file == QLatin1String("Shared")) {
|
|
||||||
// Before owncloud 7, there was no permissions system. At the time all the shared files were
|
|
||||||
// in a directory called "Shared" and were not supposed to be moved, otherwise bad things happened
|
|
||||||
|
|
||||||
QString versionString = propagator()->account()->serverVersion();
|
|
||||||
if (versionString.contains('.') && versionString.split('.')[0].toInt() < 7) {
|
|
||||||
QString originalFile(propagator()->getFilePath(QLatin1String("Shared")));
|
|
||||||
emit propagator()->touchedFile(originalFile);
|
|
||||||
emit propagator()->touchedFile(targetFile);
|
|
||||||
QString renameError;
|
|
||||||
if (FileSystem::rename(targetFile, originalFile, &renameError)) {
|
|
||||||
done(SyncFileItem::NormalError, tr("This folder must not be renamed. It is renamed back to its original name."));
|
|
||||||
} else {
|
|
||||||
done(SyncFileItem::NormalError, tr("This folder must not be renamed. Please name it back to Shared."));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString destination = QDir::cleanPath(propagator()->account()->url().path() + QLatin1Char('/')
|
QString destination = QDir::cleanPath(propagator()->account()->url().path() + QLatin1Char('/')
|
||||||
+ propagator()->account()->davPath() + propagator()->_remoteFolder + _item->_renameTarget);
|
+ propagator()->account()->davPath() + propagator()->_remoteFolder + _item->_renameTarget);
|
||||||
|
@ -137,11 +119,6 @@ void PropagateRemoteMove::slotMoveJobFinished()
|
||||||
_item->_httpErrorCode = _job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
_item->_httpErrorCode = _job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
|
||||||
if (err != QNetworkReply::NoError) {
|
if (err != QNetworkReply::NoError) {
|
||||||
if (checkForProblemsWithShared(_item->_httpErrorCode,
|
|
||||||
tr("The file was renamed but is part of a read only share. The original file was restored."))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SyncFileItem::Status status = classifyError(err, _item->_httpErrorCode,
|
SyncFileItem::Status status = classifyError(err, _item->_httpErrorCode,
|
||||||
&propagator()->_anotherSyncNeeded);
|
&propagator()->_anotherSyncNeeded);
|
||||||
done(status, _job->errorString());
|
done(status, _job->errorString());
|
||||||
|
|
|
@ -197,20 +197,13 @@ void PropagateUploadFileV1::slotPutFinished()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkReply::NetworkError err = job->reply()->error();
|
|
||||||
|
|
||||||
if (err != QNetworkReply::NoError) {
|
|
||||||
_item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
_item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
if (checkForProblemsWithShared(_item->_httpErrorCode,
|
QNetworkReply::NetworkError err = job->reply()->error();
|
||||||
tr("The file was edited locally but is part of a read only share. "
|
if (err != QNetworkReply::NoError) {
|
||||||
"It is restored and your edit is in the conflict file."))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commonErrorHandling(job);
|
commonErrorHandling(job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
|
||||||
// The server needs some time to process the request and provide us with a poll URL
|
// The server needs some time to process the request and provide us with a poll URL
|
||||||
if (_item->_httpErrorCode == 202) {
|
if (_item->_httpErrorCode == 202) {
|
||||||
_finished = true;
|
_finished = true;
|
||||||
|
|
Loading…
Reference in a new issue