Use verbose function names instead of direct member access
authorHannah von Reth <hannah.vonreth@owncloud.com>
Tue, 22 Sep 2020 09:47:40 +0000 (11:47 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:20 +0000 (10:59 +0100)
14 files changed:
src/libsync/owncloudpropagator.cpp
src/libsync/owncloudpropagator.h
src/libsync/propagatedownload.cpp
src/libsync/propagatedownloadencrypted.cpp
src/libsync/propagateremotedelete.cpp
src/libsync/propagateremotedeleteencrypted.cpp
src/libsync/propagateremotemkdir.cpp
src/libsync/propagateremotemove.cpp
src/libsync/propagateupload.cpp
src/libsync/propagateuploadencrypted.cpp
src/libsync/propagateuploadng.cpp
src/libsync/propagateuploadv1.cpp
src/libsync/propagatorjobs.cpp
src/libsync/syncengine.cpp

index b895da128b2fd7a070dda5d9dc9a6768b51c7b6f..f26dad05cd655c222a3970cc52d83a40cd81f66a 100644 (file)
@@ -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;
+}
 }
index d9b0065ee473aad9c60881e8921e68a4f117e08c..ec4faf649d52d6ae1cb83096d1a4385e16933e9b 100644 (file)
@@ -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<PropagateRootDirectory> _rootJob;
     SyncOptions _syncOptions;
     bool _jobScheduled = false;
+
+    const QString _localDir; // absolute path to the local directory. ends with '/'
+    const QString _remoteFolder; // remote folder, ends with '/'
 };
 
 
index 99ee0fe055dfc88d228cec24b5c778b192cd98c1..e032ffd6b55836b1879eb62028da9ea7ec592ad0 100644 (file)
@@ -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();
index ffef0dec6dddf6a3662a550d44c9568e8005e8f7..e8c0add00026a08ab784014048608d2c80226746 100644 (file)
@@ -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,
index 6b8776cd0f98a667a22df448bf19c85a8813135f..1499c1ab155d33262883480fc90bb1a4085c17eb 100644 (file)
@@ -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());
     }
index 1f4dd80f7bffdb32625bd3d0f4627dba05bc7aeb..76818a2b4686b3b9950f7e73235156cbbc3aa770 100644 (file)
@@ -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
index 006f1cdc888d0579ff56bcff7853b51a37107756..f29c126bbf79aaaa8bb53e4e96cb98b1cd9742f8 100644 (file)
@@ -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<DeleteJob*>(_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<QNetworkReply::NetworkError>(&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 {
index 0d7f57ce3e51791687d34cf86891b0ab71c0fa7c..df9935a7d1b89e5d301ebc3bd3a19b57fcc94d16 100644 (file)
@@ -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
index f64ef03a3cf9c908af201521db18c26b6a626f1b..8956397c8e392801ecbd803418d055cfba0a5822 100644 (file)
@@ -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;
index cccf67a1843cc7dda4ea8b9b44694aabeac8683d..cf23fffe23f5aa839240cee9ea507df63428ab5a 100644 (file)
@@ -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
index 8ed62ae0859ba27c419160df13c8d318e7e63527..8f9dfe88ed17b409d186af77a7c71d666d76bfdd 100644 (file)
@@ -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<UploadDevice>(
             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."));
index 432642f25c665a0642d14537c547f9ba4c71620c..761964c1b681857dab2d35101ca44f0d067d3bfc 100644 (file)
@@ -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<UploadDevice>(
             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."));
index 730694c0a6ae71de323cc35681cdb1e543e81676..46a078d501282e94d1a09e940cd867c8aef5aa78 100644 (file)
@@ -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<QPair<QString, bool>> 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.
index 54289d9f0e8e24c53972f30b3ed6fa0e3b2e4739..d314205b109a8aecbc36ff80e90c580b10e23188 100644 (file)
@@ -217,7 +217,7 @@ void SyncEngine::deleteStaleDownloadInfos(const SyncFileItemVector &syncItems)
     const QVector<SyncJournalDb::DownloadInfo> 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);
         }