diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index f693b12970..3eb27f0e3a 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -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) { QString msg; @@ -559,23 +505,6 @@ void OwncloudPropagator::setSyncOptions(const SyncOptions &syncOptions) _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 re = false; diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index b914be64b5..bb86275cff 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -158,8 +158,6 @@ class PropagateItemJob : public PropagatorJob protected: 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. * It is displayed in the activity view. @@ -436,8 +434,6 @@ public: /* The maximum number of active jobs in parallel */ int hardMaximumActiveJob(); - bool isInSharedDirectory(const QString &file); - /** Check whether a download would clash with an existing file * in filesystems that are only case-preserving. */ diff --git a/src/libsync/propagateremotedelete.cpp b/src/libsync/propagateremotedelete.cpp index 4ff1774669..5130ee8719 100644 --- a/src/libsync/propagateremotedelete.cpp +++ b/src/libsync/propagateremotedelete.cpp @@ -111,11 +111,6 @@ void PropagateRemoteDelete::slotDeleteJobFinished() _item->_httpErrorCode = httpStatus; 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, &propagator()->_anotherSyncNeeded); done(status, _job->errorString()); diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp index 7aa21a8a4d..b2bf68959c 100644 --- a/src/libsync/propagateremotemove.cpp +++ b/src/libsync/propagateremotemove.cpp @@ -88,24 +88,6 @@ void PropagateRemoteMove::start() finalize(); 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('/') + propagator()->account()->davPath() + propagator()->_remoteFolder + _item->_renameTarget); @@ -137,11 +119,6 @@ void PropagateRemoteMove::slotMoveJobFinished() _item->_httpErrorCode = _job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); 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, &propagator()->_anotherSyncNeeded); done(status, _job->errorString()); diff --git a/src/libsync/propagateuploadv1.cpp b/src/libsync/propagateuploadv1.cpp index 16731a9484..14a1421616 100644 --- a/src/libsync/propagateuploadv1.cpp +++ b/src/libsync/propagateuploadv1.cpp @@ -197,20 +197,13 @@ void PropagateUploadFileV1::slotPutFinished() return; } + _item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); QNetworkReply::NetworkError err = job->reply()->error(); - if (err != QNetworkReply::NoError) { - _item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - if (checkForProblemsWithShared(_item->_httpErrorCode, - tr("The file was edited locally but is part of a read only share. " - "It is restored and your edit is in the conflict file."))) { - return; - } commonErrorHandling(job); 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 if (_item->_httpErrorCode == 202) { _finished = true;