From: Hannah von Reth Date: Tue, 22 Sep 2020 09:47:40 +0000 (+0200) Subject: Use verbose function names instead of direct member access X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~55 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=93152761a1c92a3e9b93bf8e8874a68497439ee2;p=nextcloud-desktop.git Use verbose function names instead of direct member access --- diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index b895da128..f26dad05c 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -581,11 +581,16 @@ bool OwncloudPropagator::hasCaseClashAccessibilityProblem(const QString &relfile #endif } -QString OwncloudPropagator::getFilePath(const QString &tmp_file_name) const +QString OwncloudPropagator::fullLocalPath(const QString &tmp_file_name) const { return _localDir + tmp_file_name; } +QString OwncloudPropagator::localPath() const +{ + return _localDir; +} + void OwncloudPropagator::scheduleNextJob() { if (_jobScheduled) return; // don't schedule more than 1 @@ -657,7 +662,7 @@ OwncloudPropagator::DiskSpaceResult OwncloudPropagator::diskSpaceCheck() const bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item, PropagatorCompositeJob *composite, QString *error) { - QString fn = getFilePath(item->_file); + QString fn = fullLocalPath(item->_file); QString renameError; auto conflictModTime = FileSystem::getModTime(fn); @@ -666,7 +671,7 @@ bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item, conflictUserName = account()->davDisplayName(); QString conflictFileName = Utility::makeConflictFileName( item->_file, Utility::qDateTimeFromTime_t(conflictModTime), conflictUserName); - QString conflictFilePath = getFilePath(conflictFileName); + QString conflictFilePath = fullLocalPath(conflictFileName); emit touchedFile(fn); emit touchedFile(conflictFilePath); @@ -973,7 +978,7 @@ void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status) if (_item->_instruction == CSYNC_INSTRUCTION_NEW && _item->_direction == SyncFileItem::Down) { // special case for local MKDIR, set local directory mtime // (it's not synced later at all, but can be nice to have it set initially) - FileSystem::setModTime(propagator()->getFilePath(_item->destination()), _item->_modtime); + FileSystem::setModTime(propagator()->fullLocalPath(_item->destination()), _item->_modtime); } // For new directories we always want to update the etag once @@ -1125,4 +1130,15 @@ void CleanupPollsJob::slotPollFinished() // Continue with the next entry, or finish start(); } + +QString OwncloudPropagator::fullRemotePath(const QString &tmp_file_name) const +{ + // TODO: should this be part of the _item (SyncFileItemPtr)? + return _remoteFolder + tmp_file_name; +} + +QString OwncloudPropagator::remotePath() const +{ + return _remoteFolder; +} } diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index d9b0065ee..ec4faf649 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -390,9 +390,6 @@ class OWNCLOUDSYNC_EXPORT OwncloudPropagator : public QObject { Q_OBJECT public: - const QString _localDir; // absolute path to the local directory. ends with '/' - const QString _remoteFolder; // remote folder, ends with '/' - SyncJournalDb *const _journal; bool _finishedEmited; // used to ensure that finished is only emitted once @@ -479,8 +476,15 @@ public: */ bool hasCaseClashAccessibilityProblem(const QString &relfile); - /* returns the local file path for the given tmp_file_name */ - QString getFilePath(const QString &tmp_file_name) const; + Q_REQUIRED_RESULT QString fullLocalPath(const QString &tmp_file_name) const; + QString localPath() const; + + /** + * Returns the full remote path including the folder root of a + * folder sync path. + */ + Q_REQUIRED_RESULT QString fullRemotePath(const QString &tmp_file_name) const; + QString remotePath() const; /** Creates the job for an item. */ @@ -591,6 +595,9 @@ private: QScopedPointer _rootJob; SyncOptions _syncOptions; bool _jobScheduled = false; + + const QString _localDir; // absolute path to the local directory. ends with '/' + const QString _remoteFolder; // remote folder, ends with '/' }; diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 99ee0fe05..e032ffd6b 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -368,7 +368,7 @@ void PropagateDownloadFile::start() qCDebug(lcPropagateDownload) << _item->_file << propagator()->_activeJobList.count(); const auto rootPath = [=]() { - const auto result = propagator()->_remoteFolder; + const auto result = propagator()->remotePath(); if (result.startsWith('/')) { return result.mid(1); } else { @@ -416,7 +416,7 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked() // For virtual files just dehydrate or create the file and be done if (_item->_type == ItemTypeVirtualFileDehydration) { - QString fsPath = propagator()->getFilePath(_item->_file); + QString fsPath = propagator()->fullLocalPath(_item->_file); if (!FileSystem::verifyFileUnchanged(fsPath, _item->_previousSize, _item->_previousModtime)) { propagator()->_anotherSyncNeeded = true; done(SyncFileItem::SoftError, tr("File has changed since discovery")); @@ -473,7 +473,7 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked() connect(computeChecksum, &ComputeChecksum::done, this, &PropagateDownloadFile::conflictChecksumComputed); propagator()->_activeJobList.append(this); - computeChecksum->start(propagator()->getFilePath(_item->_file)); + computeChecksum->start(propagator()->fullLocalPath(_item->_file)); return; } @@ -489,7 +489,7 @@ void PropagateDownloadFile::conflictChecksumComputed(const QByteArray &checksumT // Apply the server mtime locally if necessary, ensuring the journal // and local mtimes end up identical - auto fn = propagator()->getFilePath(_item->_file); + auto fn = propagator()->fullLocalPath(_item->_file); if (_item->_modtime != _item->_previousModtime) { FileSystem::setModTime(fn, _item->_modtime); emit propagator()->touchedFile(fn); @@ -520,7 +520,7 @@ void PropagateDownloadFile::startDownload() if (progressInfo._valid) { // if the etag has changed meanwhile, remove the already downloaded part. if (progressInfo._etag != _item->_etag) { - FileSystem::remove(propagator()->getFilePath(progressInfo._tmpfile)); + FileSystem::remove(propagator()->fullLocalPath(progressInfo._tmpfile)); propagator()->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo()); } else { tmpFileName = progressInfo._tmpfile; @@ -531,7 +531,7 @@ void PropagateDownloadFile::startDownload() if (tmpFileName.isEmpty()) { tmpFileName = createDownloadTmpFileName(_item->_file); } - _tmpFile.setFileName(propagator()->getFilePath(tmpFileName)); + _tmpFile.setFileName(propagator()->fullLocalPath(tmpFileName)); _resumeStart = _tmpFile.size(); if (_resumeStart > 0 && _resumeStart == _item->_size) { @@ -589,7 +589,7 @@ void PropagateDownloadFile::startDownload() if (_item->_directDownloadUrl.isEmpty()) { // Normal job, download from oC instance _job = new GETFileJob(propagator()->account(), - propagator()->_remoteFolder + (_isEncrypted ? _item->_encryptedFileName : _item->_file), + propagator()->fullRemotePath(_isEncrypted ? _item->_encryptedFileName : _item->_file), &_tmpFile, headers, expectedEtagForResume, _resumeStart, this); } else { // We were provided a direct URL, use that one @@ -811,7 +811,7 @@ void PropagateDownloadFile::slotChecksumFail(const QString &errMsg) void PropagateDownloadFile::deleteExistingFolder() { - QString existingDir = propagator()->getFilePath(_item->_file); + QString existingDir = propagator()->fullLocalPath(_item->_file); if (!QFileInfo(existingDir).isDir()) { return; } @@ -946,7 +946,8 @@ void PropagateDownloadFile::contentChecksumComputed(const QByteArray &checksumTy void PropagateDownloadFile::downloadFinished() { - QString fn = propagator()->getFilePath(_item->_file); + ASSERT(!_tmpFile.isOpen()); + QString fn = propagator()->fullLocalPath(_item->_file); // In case of file name clash, report an error // This can happen if another parallel download saved a clashing file. @@ -1035,7 +1036,7 @@ void PropagateDownloadFile::downloadFinished() // entry, remove it transfer its old pin state. if (_item->_type == ItemTypeVirtualFileDownload) { QString virtualFile = _item->_file + vfs->fileSuffix(); - auto fn = propagator()->getFilePath(virtualFile); + auto fn = propagator()->fullLocalPath(virtualFile); qCDebug(lcPropagateDownload) << "Download of previous virtual file finished" << fn; QFile::remove(fn); propagator()->_journal->deleteFileRecord(virtualFile); @@ -1059,7 +1060,7 @@ void PropagateDownloadFile::downloadFinished() void PropagateDownloadFile::updateMetadata(bool isConflict) { - QString fn = propagator()->getFilePath(_item->_file); + QString fn = propagator()->fullLocalPath(_item->_file); if (!propagator()->updateMetadata(*_item)) { done(SyncFileItem::FatalError, tr("Error writing metadata to the database")); @@ -1079,8 +1080,8 @@ void PropagateDownloadFile::updateMetadata(bool isConflict) // handle the special recall file if (!_item->_remotePerm.hasPermission(RemotePermissions::IsShared) && (_item->_file == QLatin1String(".sys.admin#recall#") - || _item->_file.endsWith("/.sys.admin#recall#"))) { - handleRecallFile(fn, propagator()->_localDir, *propagator()->_journal); + || _item->_file.endsWith(QLatin1String("/.sys.admin#recall#")))) { + handleRecallFile(fn, propagator()->localPath(), *propagator()->_journal); } qint64 duration = _stopwatch.elapsed(); diff --git a/src/libsync/propagatedownloadencrypted.cpp b/src/libsync/propagatedownloadencrypted.cpp index ffef0dec6..e8c0add00 100644 --- a/src/libsync/propagatedownloadencrypted.cpp +++ b/src/libsync/propagatedownloadencrypted.cpp @@ -22,7 +22,7 @@ void PropagateDownloadEncrypted::start() { void PropagateDownloadEncrypted::checkFolderEncryptedStatus() { const auto rootPath = [=]() { - const auto result = _propagator->_remoteFolder; + const auto result = _propagator->remotePath(); if (result.startsWith('/')) { return result.mid(1); } else { @@ -129,7 +129,7 @@ bool PropagateDownloadEncrypted::decryptFile(QFile& tmpFile) qCDebug(lcPropagateDownloadEncrypted) << "Content Checksum Computed starting decryption" << tmpFileName; tmpFile.close(); - QFile _tmpOutput(_propagator->getFilePath(tmpFileName), this); + QFile _tmpOutput(_propagator->fullLocalPath(tmpFileName), this); EncryptionHelper::fileDecryption(_encryptedInfo.encryptionKey, _encryptedInfo.initializationVector, &tmpFile, diff --git a/src/libsync/propagateremotedelete.cpp b/src/libsync/propagateremotedelete.cpp index 6b8776cd0..1499c1ab1 100644 --- a/src/libsync/propagateremotedelete.cpp +++ b/src/libsync/propagateremotedelete.cpp @@ -101,8 +101,8 @@ void PropagateRemoteDelete::createDeleteJob(const QString &filename) qCInfo(lcPropagateRemoteDelete) << "Deleting file, local" << _item->_file << "remote" << filename; _job = new DeleteJob(propagator()->account(), - propagator()->_remoteFolder + filename, - this); + propagator()->fullRemotePath(_item->_file), + this); if (_deleteEncryptedHelper && !_deleteEncryptedHelper->folderToken().isEmpty()) { _job->setFolderToken(_deleteEncryptedHelper->folderToken()); } diff --git a/src/libsync/propagateremotedeleteencrypted.cpp b/src/libsync/propagateremotedeleteencrypted.cpp index 1f4dd80f7..76818a2b4 100644 --- a/src/libsync/propagateremotedeleteencrypted.cpp +++ b/src/libsync/propagateremotedeleteencrypted.cpp @@ -79,7 +79,7 @@ void PropagateRemoteDeleteEncrypted::slotFolderEncryptedMetadataReceived(const Q // Encrypt File! FolderMetadata metadata(_propagator->account(), json.toJson(QJsonDocument::Compact), statusCode); - QFileInfo info(_propagator->_localDir + QDir::separator() + _item->_file); + QFileInfo info(_propagator->fullLocalPath(_item->_file)); const QString fileName = info.fileName(); // Find existing metadata for this file diff --git a/src/libsync/propagateremotemkdir.cpp b/src/libsync/propagateremotemkdir.cpp index 006f1cdc8..f29c126bb 100644 --- a/src/libsync/propagateremotemkdir.cpp +++ b/src/libsync/propagateremotemkdir.cpp @@ -35,7 +35,7 @@ PropagateRemoteMkdir::PropagateRemoteMkdir(OwncloudPropagator *propagator, const , _parallelism(FullParallelism) { const auto rootPath = [=]() { - const auto result = propagator->_remoteFolder; + const auto result = propagator->remotePath(); if (result.startsWith('/')) { return result.mid(1); } else { @@ -82,7 +82,7 @@ void PropagateRemoteMkdir::start() } _job = new DeleteJob(propagator()->account(), - propagator()->_remoteFolder + _item->_file, + propagator()->fullRemotePath(_item->_file), this); connect(static_cast(_job.data()), &DeleteJob::finishedSignal, this, &PropagateRemoteMkdir::slotMkdir); @@ -97,7 +97,7 @@ void PropagateRemoteMkdir::slotStartMkcolJob() qCDebug(lcPropagateRemoteMkdir) << _item->_file; _job = new MkColJob(propagator()->account(), - propagator()->_remoteFolder + _item->_file, + propagator()->fullRemotePath(_item->_file), this); connect(_job, SIGNAL(finished(QNetworkReply::NetworkError)), this, SLOT(slotMkcolJobFinished())); _job->start(); @@ -115,7 +115,7 @@ void PropagateRemoteMkdir::slotStartEncryptedMkcolJob(const QString &path, const qCDebug(lcPropagateRemoteMkdir) << filename; auto job = new MkColJob(propagator()->account(), - propagator()->_remoteFolder + filename, + propagator()->fullRemotePath(filename), {{"e2e-token", _uploadEncryptedHelper->_folderToken }}, this); connect(job, qOverload(&MkColJob::finished), @@ -144,7 +144,7 @@ void PropagateRemoteMkdir::setDeleteExisting(bool enabled) void PropagateRemoteMkdir::slotMkdir() { const auto rootPath = [=]() { - const auto result = propagator()->_remoteFolder; + const auto result = propagator()->remotePath(); if (result.startsWith('/')) { return result.mid(1); } else { diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp index 0d7f57ce3..df9935a7d 100644 --- a/src/libsync/propagateremotemove.cpp +++ b/src/libsync/propagateremotemove.cpp @@ -81,7 +81,7 @@ void PropagateRemoteMove::start() QString origin = propagator()->adjustRenamedPath(_item->_file); qCDebug(lcPropagateRemoteMove) << origin << _item->_renameTarget; - QString targetFile(propagator()->getFilePath(_item->_renameTarget)); + QString targetFile(propagator()->fullLocalPath(_item->_renameTarget)); if (origin == _item->_renameTarget) { // The parent has been renamed already so there is nothing more to do. @@ -89,8 +89,8 @@ void PropagateRemoteMove::start() return; } - QString remoteSource = propagator()->_remoteFolder + origin; - QString remoteDestination = QDir::cleanPath(propagator()->account()->davUrl().path() + propagator()->_remoteFolder + _item->_renameTarget); + QString remoteSource = propagator()->fullRemotePath(origin); + QString remoteDestination = QDir::cleanPath(propagator()->account()->davUrl().path() + propagator()->fullRemotePath(_item->_renameTarget)); auto &vfs = propagator()->syncOptions()._vfs; auto itype = _item->_type; @@ -130,8 +130,8 @@ void PropagateRemoteMove::start() folderTargetAlt.chop(suffix.size()); } - QString localTarget = propagator()->getFilePath(folderTarget); - QString localTargetAlt = propagator()->getFilePath(folderTargetAlt); + QString localTarget = propagator()->fullLocalPath(folderTarget); + QString localTargetAlt = propagator()->fullLocalPath(folderTargetAlt); // If the expected target doesn't exist but a file with different hydration // state does, rename the local file to bring it in line with what the discovery diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index f64ef03a3..8956397c8 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -197,7 +197,7 @@ PropagateUploadFileCommon::PropagateUploadFileCommon(OwncloudPropagator *propaga , _uploadingEncrypted(false) { const auto rootPath = [=]() { - const auto result = propagator->_remoteFolder; + const auto result = propagator->remotePath(); if (result.startsWith('/')) { return result.mid(1); } else { @@ -237,7 +237,7 @@ void PropagateUploadFileCommon::setDeleteExisting(bool enabled) void PropagateUploadFileCommon::start() { const auto rootPath = [=]() { - const auto result = propagator()->_remoteFolder; + const auto result = propagator()->remotePath(); if (result.startsWith('/')) { return result.mid(1); } else { @@ -290,7 +290,7 @@ void PropagateUploadFileCommon::setupUnencryptedFile() _uploadingEncrypted = false; _fileToUpload._file = _item->_file; _fileToUpload._size = _item->_size; - _fileToUpload._path = propagator()->getFilePath(_fileToUpload._file); + _fileToUpload._path = propagator()->fullLocalPath(_fileToUpload._file); startUploadFile(); } @@ -325,7 +325,7 @@ void PropagateUploadFileCommon::startUploadFile() { qDebug() << "Deleting the current"; auto job = new DeleteJob(propagator()->account(), - propagator()->_remoteFolder + _fileToUpload._file, + propagator()->fullRemotePath(_fileToUpload._file), this); _jobs.append(job); connect(job, &DeleteJob::finishedSignal, this, &PropagateUploadFileCommon::slotComputeContentChecksum); @@ -341,7 +341,7 @@ void PropagateUploadFileCommon::slotComputeContentChecksum() return; } - const QString filePath = propagator()->getFilePath(_item->_file); + const QString filePath = propagator()->fullLocalPath(_item->_file); // remember the modtime before checksumming to be able to detect a file // change during the checksum calculation - This goes inside of the _item->_file @@ -397,7 +397,7 @@ void PropagateUploadFileCommon::slotComputeTransmissionChecksum(const QByteArray this, &PropagateUploadFileCommon::slotStartUpload); connect(computeChecksum, &ComputeChecksum::done, computeChecksum, &QObject::deleteLater); - const QString filePath = propagator()->getFilePath(_item->_file); + const QString filePath = propagator()->fullLocalPath(_item->_file); computeChecksum->start(filePath); } @@ -414,8 +414,8 @@ void PropagateUploadFileCommon::slotStartUpload(const QByteArray &transmissionCh _item->_checksumHeader = _transmissionChecksumHeader; } - const QString fullFilePath = _fileToUpload._path; - const QString originalFilePath = propagator()->getFilePath(_item->_file); + const QString fullFilePath = propagator()->fullLocalPath(_fileToUpload._file); + const QString originalFilePath = propagator()->fullLocalPath(_item->_file); if (!FileSystem::fileExists(fullFilePath)) { if (_uploadingEncrypted) { @@ -613,7 +613,7 @@ void UploadDevice::setChoked(bool b) void PropagateUploadFileCommon::startPollJob(const QString &path) { auto *job = new PollJob(propagator()->account(), path, _item, - propagator()->_journal, propagator()->_localDir, this); + propagator()->_journal, propagator()->localPath(), this); connect(job, &PollJob::finishedSignal, this, &PropagateUploadFileCommon::slotPollFinished); SyncJournalDb::PollInfo info; info._file = _item->_file; diff --git a/src/libsync/propagateuploadencrypted.cpp b/src/libsync/propagateuploadencrypted.cpp index cccf67a18..cf23fffe2 100644 --- a/src/libsync/propagateuploadencrypted.cpp +++ b/src/libsync/propagateuploadencrypted.cpp @@ -28,7 +28,7 @@ PropagateUploadEncrypted::PropagateUploadEncrypted(OwncloudPropagator *propagato void PropagateUploadEncrypted::start() { const auto rootPath = [=]() { - const auto result = _propagator->_remoteFolder; + const auto result = _propagator->remotePath(); if (result.startsWith('/')) { return result.mid(1); } else { @@ -147,7 +147,7 @@ void PropagateUploadEncrypted::slotFolderEncryptedMetadataReceived(const QJsonDo // Encrypt File! _metadata = new FolderMetadata(_propagator->account(), json.toJson(QJsonDocument::Compact), statusCode); - QFileInfo info(_propagator->_localDir + QDir::separator() + _item->_file); + QFileInfo info(_propagator->fullLocalPath(_item->_file)); const QString fileName = info.fileName(); // Find existing metadata for this file diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index 8ed62ae08..8f9dfe88e 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -291,7 +291,7 @@ void PropagateUploadFileNG::startNextChunk() // Finish with a MOVE // If we changed the file name, we must store the changed filename in the remote folder, not the original one. QString destination = QDir::cleanPath(propagator()->account()->davUrl().path() - + propagator()->_remoteFolder + _fileToUpload._file); + + propagator()->fullRemotePath(_fileToUpload._file)); auto headers = PropagateUploadFileCommon::headers(); // "If-Match applies to the source, but we are interested in comparing the etag of the destination @@ -316,7 +316,7 @@ void PropagateUploadFileNG::startNextChunk() return; } - const QString fileName = _fileToUpload._path; + const QString fileName = propagator()->fullLocalPath(_fileToUpload._file); auto device = std::make_unique( fileName, _currentChunk, _currentChunkSize, &propagator()->_bandwidthManager); if (!device->open(QIODevice::ReadOnly)) { @@ -410,7 +410,7 @@ void PropagateUploadFileNG::slotPutFinished() _finished = _sent == _item->_size; // Check if the file still exists - const QString fullFilePath(propagator()->getFilePath(_item->_file)); + const QString fullFilePath(propagator()->fullLocalPath(_item->_file)); if (!FileSystem::fileExists(fullFilePath)) { if (!_finished) { abortWithError(SyncFileItem::SoftError, tr("The local file was removed during sync.")); diff --git a/src/libsync/propagateuploadv1.cpp b/src/libsync/propagateuploadv1.cpp index 432642f25..761964c1b 100644 --- a/src/libsync/propagateuploadv1.cpp +++ b/src/libsync/propagateuploadv1.cpp @@ -118,11 +118,11 @@ void PropagateUploadFileV1::startNextChunk() qCDebug(lcPropagateUploadV1) << _chunkCount << isFinalChunk << chunkStart << currentChunkSize; if (isFinalChunk && !_transmissionChecksumHeader.isEmpty()) { - qCInfo(lcPropagateUploadV1) << propagator()->_remoteFolder + path << _transmissionChecksumHeader; + qCInfo(lcPropagateUploadV1) << propagator()->fullRemotePath(path) << _transmissionChecksumHeader; headers[checkSumHeaderC] = _transmissionChecksumHeader; } - const QString fileName = _fileToUpload._path; + const QString fileName = propagator()->fullLocalPath(_fileToUpload._file); auto device = std::make_unique( fileName, chunkStart, currentChunkSize, &propagator()->_bandwidthManager); if (!device->open(QIODevice::ReadOnly)) { @@ -140,7 +140,7 @@ void PropagateUploadFileV1::startNextChunk() // job takes ownership of device via a QScopedPointer. Job deletes itself when finishing auto devicePtr = device.get(); // for connections later - auto *job = new PUTFileJob(propagator()->account(), propagator()->_remoteFolder + path, std::move(device), headers, _currentChunk, this); + auto *job = new PUTFileJob(propagator()->account(), propagator()->fullRemotePath(path), std::move(device), headers, _currentChunk, this); _jobs.append(job); connect(job, &PUTFileJob::finishedSignal, this, &PropagateUploadFileV1::slotPutFinished); connect(job, &PUTFileJob::uploadProgress, this, &PropagateUploadFileV1::slotUploadProgress); @@ -233,11 +233,8 @@ void PropagateUploadFileV1::slotPutFinished() QByteArray etag = getEtagFromReply(job->reply()); _finished = etag.length() > 0; - /* Check if the file still exists, - * but we could be operating in a temporary file, so check both if - * the file to upload is different than the file on disk - */ - const QString fullFilePath(propagator()->getFilePath(_item->_file)); + // Check if the file still exists + const QString fullFilePath(propagator()->fullLocalPath(_item->_file)); if (!FileSystem::fileExists(fullFilePath)) { if (!_finished) { abortWithError(SyncFileItem::SoftError, tr("The local file was removed during sync.")); diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index 730694c0a..46a078d50 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -56,8 +56,7 @@ QByteArray localFileIdFromFullId(const QByteArray &id) */ bool PropagateLocalRemove::removeRecursively(const QString &path) { - auto folderDir = propagator()->_localDir; - QString absolute = folderDir + _item->_file + path; + QString absolute = propagator()->fullLocalPath(_item->_file + path); QStringList errors; QList> deleted; bool success = FileSystem::removeRecursively( @@ -73,14 +72,14 @@ bool PropagateLocalRemove::removeRecursively(const QString &path) // Do it while avoiding redundant delete calls to the journal. QString deletedDir; foreach (const auto &it, deleted) { - if (!it.first.startsWith(folderDir)) + if (!it.first.startsWith(propagator()->localPath())) continue; if (!deletedDir.isEmpty() && it.first.startsWith(deletedDir)) continue; if (it.second) { deletedDir = it.first; } - propagator()->_journal->deleteFileRecord(it.first.mid(folderDir.size()), it.second); + propagator()->_journal->deleteFileRecord(it.first.mid(propagator()->localPath().size()), it.second); } _error = errors.join(", "); @@ -95,7 +94,7 @@ void PropagateLocalRemove::start() if (propagator()->_abortRequested) return; - QString filename = propagator()->_localDir + _item->_file; + const QString filename = propagator()->fullLocalPath(_item->_file); qCDebug(lcPropagateLocalRemove) << filename; if (propagator()->localFileNameClash(_item->_file)) { @@ -136,7 +135,7 @@ void PropagateLocalMkdir::start() return; const auto rootPath = [=]() { - const auto result = propagator()->_remoteFolder; + const auto result = propagator()->remotePath(); if (result.startsWith('/')) { return result.mid(1); } else { @@ -169,7 +168,7 @@ void PropagateLocalMkdir::setDeleteExistingFile(bool enabled) void PropagateLocalMkdir::startLocalMkdir() { - QDir newDir(propagator()->getFilePath(_item->_file)); + QDir newDir(propagator()->fullLocalPath(_item->_file)); QString newDirStr = QDir::toNativeSeparators(newDir.path()); // When turning something that used to be a file into a directory @@ -199,7 +198,7 @@ void PropagateLocalMkdir::startLocalMkdir() return; } emit propagator()->touchedFile(newDirStr); - QDir localDir(propagator()->_localDir); + QDir localDir(propagator()->localPath()); if (!localDir.mkpath(_item->_file)) { done(SyncFileItem::NormalError, tr("could not create folder %1").arg(newDirStr)); return; @@ -247,8 +246,8 @@ void PropagateLocalRename::start() if (propagator()->_abortRequested) return; - QString existingFile = propagator()->getFilePath(propagator()->adjustRenamedPath(_item->_file)); - QString targetFile = propagator()->getFilePath(_item->_renameTarget); + QString existingFile = propagator()->fullLocalPath(propagator()->adjustRenamedPath(_item->_file)); + QString targetFile = propagator()->fullLocalPath(_item->_renameTarget); // if the file is a file underneath a moved dir, the _item->file is equal // to _item->renameTarget and the file is not moved as a result. diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 54289d9f0..d314205b1 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -217,7 +217,7 @@ void SyncEngine::deleteStaleDownloadInfos(const SyncFileItemVector &syncItems) const QVector deleted_infos = _journal->getAndDeleteStaleDownloadInfos(download_file_paths); foreach (const SyncJournalDb::DownloadInfo &deleted_info, deleted_infos) { - const QString tmppath = _propagator->getFilePath(deleted_info._tmpfile); + const QString tmppath = _propagator->fullLocalPath(deleted_info._tmpfile); qCInfo(lcEngine) << "Deleting stale temporary file: " << tmppath; FileSystem::remove(tmppath); } @@ -274,7 +274,7 @@ void SyncEngine::conflictRecordMaintenance() // missing ones. const auto conflictRecordPaths = _journal->conflictRecordPaths(); for (const auto &path : conflictRecordPaths) { - auto fsPath = _propagator->getFilePath(QString::fromUtf8(path)); + auto fsPath = _propagator->fullLocalPath(QString::fromUtf8(path)); if (!QFileInfo(fsPath).exists()) { _journal->deleteConflictRecord(path); }