diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 7db47008c5d..daf23d00849 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -470,19 +470,18 @@ void Folder::showSyncResultPopup() LogStatus status(LogStatusRename); // if the path changes it's rather a move QDir renTarget = QFileInfo(_syncResult.firstItemRenamed()->_renameTarget).dir(); - QDir renSource = QFileInfo(_syncResult.firstItemRenamed()->_file).dir(); + QDir renSource = QFileInfo(_syncResult.firstItemRenamed()->localName()).dir(); if (renTarget != renSource) { status = LogStatusMove; } - createGuiLog(_syncResult.firstItemRenamed()->_file, status, - _syncResult.numRenamedItems(), _syncResult.firstItemRenamed()->_renameTarget); + createGuiLog(_syncResult.firstItemRenamed()->localName(), status, _syncResult.numRenamedItems(), _syncResult.firstItemRenamed()->_renameTarget); } if (_syncResult.firstNewConflictItem()) { createGuiLog(_syncResult.firstNewConflictItem()->destination(), LogStatusConflict, _syncResult.numNewConflictItems()); } if (int errorCount = _syncResult.numErrorItems()) { - createGuiLog(_syncResult.firstItemError()->_file, LogStatusError, errorCount); + createGuiLog(_syncResult.firstItemError()->localName(), LogStatusError, errorCount); } qCInfo(lcFolder) << "Folder" << path() << "sync result: " << _syncResult.status(); diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 13c10cc6d56..c3636e3ab66 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -97,13 +97,13 @@ namespace { } else { estimatedUpBw += progress.fileProgress(citm._item).estimatedBandwidth; } - allFilenames.append(QApplication::translate("FolderStatus", "'%1'").arg(citm._item._file)); + allFilenames.append(QApplication::translate("FolderStatus", "'%1'").arg(citm._item.localName())); } if (curItemProgress == -1) { curItemProgress = curItem._size; } - const QString itemFileName = curItem._file; + const QString itemFileName = curItem.localName(); const QString kindString = Progress::asActionString(curItem); QString fileProgressString; diff --git a/src/gui/issueswidget.cpp b/src/gui/issueswidget.cpp index 9b37a1d80b3..6ae5338ae94 100644 --- a/src/gui/issueswidget.cpp +++ b/src/gui/issueswidget.cpp @@ -202,9 +202,8 @@ IssuesWidget::IssuesWidget(QWidget *parent) }); connect(ProgressDispatcher::instance(), &ProgressDispatcher::excluded, this, [this](Folder *f, const QString &file) { - auto item = SyncFileItemPtr::create(); + auto item = SyncFileItemPtr::create(file); item->_status = SyncFileItem::FilenameReserved; - item->_file = file; item->_errorString = tr("The file %1 was ignored as its name is reserved by %2").arg(file, Theme::instance()->appNameGUI()); _model->addProtocolItem(ProtocolItem { f, item }); }); diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 5e86886cb1f..a34c5b48eed 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -804,9 +804,9 @@ void ownCloudGui::slotUpdateProgress(Folder *folder, const ProgressInfo &progres if (!progress._lastCompletedItem.isEmpty() && shouldShowInRecentsMenu(progress._lastCompletedItem)) { QString kindStr = Progress::asResultString(progress._lastCompletedItem); QString timeStr = QTime::currentTime().toString(QStringLiteral("hh:mm")); - QString actionText = tr("%1 (%2, %3)").arg(progress._lastCompletedItem._file, kindStr, timeStr); + QString actionText = tr("%1 (%2, %3)").arg(progress._lastCompletedItem.localName(), kindStr, timeStr); QAction *action = new QAction(actionText, this); - QString fullPath = folder->path() + QLatin1Char('/') + progress._lastCompletedItem._file; + QString fullPath = folder->path() + QLatin1Char('/') + progress._lastCompletedItem.localName(); if (QFile(fullPath).exists()) { connect(action, &QAction::triggered, this, [this, fullPath] { this->slotOpenPath(fullPath); }); } else { diff --git a/src/gui/syncrunfilelog.cpp b/src/gui/syncrunfilelog.cpp index 599bdc1b2bd..c7881c73b01 100644 --- a/src/gui/syncrunfilelog.cpp +++ b/src/gui/syncrunfilelog.cpp @@ -87,7 +87,7 @@ void SyncRunFileLog::logItem(const SyncFileItem &item) { QDebug(&tmp).noquote() << dateTimeStr(Utility::parseRFC1123Date(QString::fromUtf8(item._responseTimeStamp))) << L << ((item.instruction() != CSYNC_INSTRUCTION_RENAME) ? item.destination() - : item._file + QStringLiteral(" -> ") + item._renameTarget) + : item.localName() + QStringLiteral(" -> ") + item._renameTarget) << L << item.instruction() << L << item._direction << L << L << item._modtime << L << item._etag << L << item._size << L << item._fileId << L << item._status << L << item._errorString << L << item._httpErrorCode << L << item._previousSize << L << item._previousModtime << L << item._requestId << L << Qt::endl; diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 293b82a6c82..7d787d8ee66 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -158,7 +158,7 @@ void ProcessDirectoryJob::process() path._local = PathTuple::pathAppend(_currentFolder._local, e.localEntry.name); } else if (e.dbEntry.isVirtualFile()) { // We don't have a local entry - but it should be at this path - addVirtualFileSuffix(path._local); + path._local = addVirtualFileSuffix(path._local); } } @@ -226,8 +226,7 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const QString &loc return true; } - auto item = SyncFileItemPtr::create(); - item->_file = path; + auto item = SyncFileItemPtr::create(path); item->_originalFile = path; item->setInstruction(CSYNC_INSTRUCTION_IGNORE); @@ -246,7 +245,7 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const QString &loc item->_status = SyncFileItem::Excluded; break; case CSYNC_FILE_EXCLUDE_INVALID_CHAR: - if (item->_file.endsWith(QLatin1Char('.'))) { + if (item->localName().endsWith(QLatin1Char('.'))) { item->_errorString = tr("File names ending with a period are not supported on this file system."); } else { const auto unsupportedCharacter = [](const QString &fName) { @@ -257,7 +256,7 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const QString &loc } } return QChar(); - }(item->_file); + }(item->localName()); if (!unsupportedCharacter.isNull()) { item->_errorString = tr("File names containing the character '%1' are not supported on this file system.") @@ -336,7 +335,7 @@ void ProcessDirectoryJob::processFile(const PathTuple &path, } auto item = SyncFileItem::fromSyncJournalFileRecord(dbEntry); - item->_file = path._target; + item->setLocalName(path._target); item->_originalFile = path._original; item->_previousSize = dbEntry._fileSize; item->_previousModtime = dbEntry._modtime; @@ -494,7 +493,7 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo( && _pinState != PinState::AlwaysLocal) { item->_type = ItemTypeVirtualFile; if (isVfsWithSuffix()) { - addVirtualFileSuffix(path._original); + path._original = addVirtualFileSuffix(path._original); } } processFileAnalyzeLocalInfo(item, path, localEntry, serverEntry, dbEntry, _queryServer); @@ -593,11 +592,11 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo( item->setInstruction(CSYNC_INSTRUCTION_RENAME); item->_direction = SyncFileItem::Down; item->_renameTarget = path._target; - item->_file = adjustedOriginalPath; + item->setLocalName(adjustedOriginalPath); item->_originalFile = originalPath; path._original = originalPath; path._local = adjustedOriginalPath; - qCInfo(lcDisco) << "Rename detected (down) " << item->_file << " -> " << item->_renameTarget; + qCInfo(lcDisco) << "Rename detected (down) " << item->localName() << " -> " << item->_renameTarget; }; if (wasDeletedOnServer) { @@ -747,14 +746,14 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( // might have been renamed to that. Make sure that the base file is not // deleted from the server. if (dbEntry._modtime == localEntry.modtime && dbEntry._fileSize == localEntry.size) { - qCInfo(lcDisco) << "Base file was renamed to virtual file:" << item->_file; + qCInfo(lcDisco) << "Base file was renamed to virtual file:" << item->localName(); item->_direction = SyncFileItem::Down; item->setInstruction(CSYNC_INSTRUCTION_SYNC); item->_type = ItemTypeVirtualFileDehydration; - addVirtualFileSuffix(item->_file); - item->_renameTarget = item->_file; + item->setLocalName(addVirtualFileSuffix(item->localName())); + item->_renameTarget = item->localName(); } else { - qCInfo(lcDisco) << "Virtual file with non-virtual db entry, ignoring:" << item->_file; + qCInfo(lcDisco) << "Virtual file with non-virtual db entry, ignoring:" << item->localName(); item->setInstruction(CSYNC_INSTRUCTION_IGNORE); } } @@ -981,7 +980,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( // TODO: move to SyncFileItem so its easier to refactor if item changes in any way... item->_renameTarget = path._target; path._server = adjustedOriginalPath; - item->_file = path._server; + item->setLocalName(path._server); path._original = originalPath; item->_originalFile = path._original; item->_modtime = base._modtime; @@ -1002,7 +1001,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( item->_type = ItemTypeFile; } - qCInfo(lcDisco) << "Rename detected (up) " << item->_file << " -> " << item->_renameTarget; + qCInfo(lcDisco) << "Rename detected (up) " << item->localName() << " -> " << item->_renameTarget; return path; }; if (wasDeletedOnClient.first) { @@ -1089,7 +1088,7 @@ void ProcessDirectoryJob::processFileConflict(const SyncFileItemPtr &item, const if (item->instruction() == CSYNC_INSTRUCTION_UPDATE_METADATA) { // Update the etag and other server metadata in the journal already - Q_ASSERT(item->_file == path._original); + Q_ASSERT(item->localName() == path._original); Q_ASSERT(item->_size == serverEntry.size); Q_ASSERT(item->_modtime == serverEntry.modtime); Q_ASSERT(!serverEntry.etag.isEmpty()); @@ -1113,15 +1112,16 @@ void ProcessDirectoryJob::processFileFinalize( // Adjust target path for virtual-suffix files if (isVfsWithSuffix()) { if (item->_type == ItemTypeVirtualFile) { - addVirtualFileSuffix(path._target); - if (item->instruction() == CSYNC_INSTRUCTION_RENAME) - addVirtualFileSuffix(item->_renameTarget); - else - addVirtualFileSuffix(item->_file); + path._target = addVirtualFileSuffix(path._target); + if (item->instruction() == CSYNC_INSTRUCTION_RENAME) { + item->_renameTarget = addVirtualFileSuffix(item->_renameTarget); + } else { + item->setLocalName(addVirtualFileSuffix(item->localName())); + } } else if (item->_type == ItemTypeVirtualFileDehydration && item->instruction() == CSYNC_INSTRUCTION_SYNC) { if (item->_renameTarget.isEmpty()) { - item->_renameTarget = item->_file; - addVirtualFileSuffix(item->_renameTarget); + item->_renameTarget = item->localName(); + item->_renameTarget = addVirtualFileSuffix(item->_renameTarget); } } } @@ -1135,7 +1135,7 @@ void ProcessDirectoryJob::processFileFinalize( item->_direction = _dirItem->_direction; } - qCInfo(lcDisco) << "Discovered" << item->_file << item->instruction() << item->_direction << item->_type; + qCInfo(lcDisco) << "Discovered" << item->localName() << item->instruction() << item->_direction << item->_type; if (item->isDirectory() && item->instruction() == CSYNC_INSTRUCTION_SYNC) item->setInstruction(CSYNC_INSTRUCTION_UPDATE_METADATA); @@ -1172,7 +1172,7 @@ void ProcessDirectoryJob::processBlacklisted(const PathTuple &path, const OCC::L return; auto item = SyncFileItem::fromSyncJournalFileRecord(dbEntry); - item->_file = path._target; + item->setLocalName(path._target); item->_originalFile = path._original; item->_inode = localEntry.inode; item->_isSelectiveSync = true; @@ -1186,7 +1186,7 @@ void ProcessDirectoryJob::processBlacklisted(const PathTuple &path, const OCC::L _childIgnored = true; } - qCInfo(lcDisco) << "Discovered (blacklisted) " << item->_file << item->instruction() << item->_direction << item->isDirectory(); + qCInfo(lcDisco) << "Discovered (blacklisted) " << item->localName() << item->instruction() << item->_direction << item->isDirectory(); if (item->isDirectory() && item->instruction() != CSYNC_INSTRUCTION_IGNORE) { auto job = new ProcessDirectoryJob(path, item, NormalQuery, InBlackList, this); @@ -1213,12 +1213,12 @@ bool ProcessDirectoryJob::checkPermissions(const OCC::SyncFileItemPtr &item) // No permissions set return true; } else if (item->isDirectory() && !perms.hasPermission(RemotePermissions::CanAddSubDirectories)) { - qCWarning(lcDisco) << "checkForPermission: ERROR" << item->_file; + qCWarning(lcDisco) << "checkForPermission: ERROR" << item->localName(); item->setInstruction(CSYNC_INSTRUCTION_ERROR); item->_errorString = tr("Not allowed because you don't have permission to add subfolders to that folder"); return false; } else if (!item->isDirectory() && !perms.hasPermission(RemotePermissions::CanAddFile)) { - qCWarning(lcDisco) << "checkForPermission: ERROR" << item->_file; + qCWarning(lcDisco) << "checkForPermission: ERROR" << item->localName(); item->setInstruction(CSYNC_INSTRUCTION_ERROR); item->_errorString = tr("Not allowed because you don't have permission to add files in that folder"); return false; @@ -1236,7 +1236,7 @@ bool ProcessDirectoryJob::checkPermissions(const OCC::SyncFileItemPtr &item) item->_errorString = tr("Not allowed to upload this file because it is read-only on the server, restoring"); item->_direction = SyncFileItem::Down; item->_isRestoration = true; - qCWarning(lcDisco) << "checkForPermission: RESTORING" << item->_file << item->_errorString; + qCWarning(lcDisco) << "checkForPermission: RESTORING" << item->localName() << item->_errorString; // Take the things to write to the db from the "other" node (i.e: info from server). // Do a lookup into the csync remote tree to get the metadata we need to restore. qSwap(item->_size, item->_previousSize); @@ -1246,7 +1246,7 @@ bool ProcessDirectoryJob::checkPermissions(const OCC::SyncFileItemPtr &item) break; } case CSYNC_INSTRUCTION_REMOVE: { - QString fileSlash = item->_file + QLatin1Char('/'); + QString fileSlash = item->localName() + QLatin1Char('/'); auto forbiddenIt = _discoveryData->_forbiddenDeletes.upper_bound(fileSlash); if (forbiddenIt != _discoveryData->_forbiddenDeletes.cbegin()) { forbiddenIt--; @@ -1257,7 +1257,7 @@ bool ProcessDirectoryJob::checkPermissions(const OCC::SyncFileItemPtr &item) item->_direction = SyncFileItem::Down; item->_isRestoration = true; item->_errorString = tr("Moved to invalid target, restoring"); - qCWarning(lcDisco) << "checkForPermission: RESTORING" << item->_file << item->_errorString; + qCWarning(lcDisco) << "checkForPermission: RESTORING" << item->localName() << item->_errorString; return true; // restore sub items } const auto perms = item->_remotePerm; @@ -1270,7 +1270,7 @@ bool ProcessDirectoryJob::checkPermissions(const OCC::SyncFileItemPtr &item) item->_direction = SyncFileItem::Down; item->_isRestoration = true; item->_errorString = tr("Not allowed to remove, restoring"); - qCWarning(lcDisco) << "checkForPermission: RESTORING" << item->_file << item->_errorString; + qCWarning(lcDisco) << "checkForPermission: RESTORING" << item->localName() << item->_errorString; return true; // (we need to recurse to restore sub items) } break; @@ -1382,9 +1382,9 @@ void ProcessDirectoryJob::dbError() Q_EMIT _discoveryData->fatalError(tr("Error while reading the database")); } -void ProcessDirectoryJob::addVirtualFileSuffix(QString &str) const +QString ProcessDirectoryJob::addVirtualFileSuffix(const QString &str) const { - str.append(_discoveryData->_syncOptions._vfs->fileSuffix()); + return QString(str).append(_discoveryData->_syncOptions._vfs->fileSuffix()); } bool ProcessDirectoryJob::hasVirtualFileSuffix(const QString &str) const diff --git a/src/libsync/discovery.h b/src/libsync/discovery.h index bb8f1e88a5f..8ceb4e06ed0 100644 --- a/src/libsync/discovery.h +++ b/src/libsync/discovery.h @@ -193,7 +193,7 @@ class ProcessDirectoryJob : public QObject /** An DB operation failed */ void dbError(); - void addVirtualFileSuffix(QString &str) const; + [[nodiscard]] QString addVirtualFileSuffix(const QString &str) const; bool hasVirtualFileSuffix(const QString &str) const; Q_REQUIRED_RESULT QString chopVirtualFileSuffix(const QString &str) const; diff --git a/src/libsync/localdiscoverytracker.cpp b/src/libsync/localdiscoverytracker.cpp index 387d1599b09..9eaf780901f 100644 --- a/src/libsync/localdiscoverytracker.cpp +++ b/src/libsync/localdiscoverytracker.cpp @@ -81,8 +81,8 @@ void LocalDiscoveryTracker::slotItemCompleted(const SyncFileItemPtr &item) case SyncFileItem::Conflict: Q_FALLTHROUGH(); case OCC::SyncFileItem::Message: - if (_previousLocalDiscoveryPaths.erase(item->_file)) { - qCDebug(lcLocalDiscoveryTracker) << "wiped successful item" << item->_file; + if (_previousLocalDiscoveryPaths.erase(item->localName())) { + qCDebug(lcLocalDiscoveryTracker) << "wiped successful item" << item->localName(); } if (!item->_renameTarget.isEmpty() && _previousLocalDiscoveryPaths.erase(item->_renameTarget)) { qCDebug(lcLocalDiscoveryTracker) << "wiped successful item" << item->_renameTarget; @@ -106,8 +106,8 @@ void LocalDiscoveryTracker::slotItemCompleted(const SyncFileItemPtr &item) Q_UNREACHABLE(); } - _localDiscoveryPaths.insert(item->_file); - qCDebug(lcLocalDiscoveryTracker) << "inserted error item" << item->_file; + _localDiscoveryPaths.insert(item->localName()); + qCDebug(lcLocalDiscoveryTracker) << "inserted error item" << item->localName(); } void LocalDiscoveryTracker::slotSyncFinished(bool success) diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 0f2535ea5e5..1f40a39b418 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -145,7 +145,7 @@ static SyncJournalErrorBlacklistRecord createBlacklistEntry( const SyncJournalErrorBlacklistRecord &old, const SyncFileItem &item) { SyncJournalErrorBlacklistRecord entry; - entry._file = item._file; + entry._file = item.localName(); entry._errorString = item._errorString; entry._lastTryModtime = item._modtime; entry._lastTryEtag = item._etag.toUtf8(); @@ -187,7 +187,7 @@ static SyncJournalErrorBlacklistRecord createBlacklistEntry( */ static void blacklistUpdate(SyncJournalDb *journal, SyncFileItem &item) { - SyncJournalErrorBlacklistRecord oldEntry = journal->errorBlacklistEntry(item._file); + SyncJournalErrorBlacklistRecord oldEntry = journal->errorBlacklistEntry(item.localName()); const bool mayBlacklist = item._status == SyncFileItem::NormalError || item._status == SyncFileItem::SoftError @@ -196,7 +196,7 @@ static void blacklistUpdate(SyncJournalDb *journal, SyncFileItem &item) // No new entry? Possibly remove the old one, then done. if (!mayBlacklist) { if (oldEntry.isValid()) { - journal->wipeErrorBlacklistEntry(item._file); + journal->wipeErrorBlacklistEntry(item.localName()); } return; } @@ -211,16 +211,13 @@ static void blacklistUpdate(SyncJournalDb *journal, SyncFileItem &item) if (item._status == SyncFileItem::SoftError && newEntry._retryCount > 1 && item._httpErrorCode != 0) { - qCWarning(lcPropagator) << "escalating http soft error on " << item._file - << " to normal error, " << item._httpErrorCode; + qCWarning(lcPropagator) << "escalating http soft error on " << item.localName() << " to normal error, " << item._httpErrorCode; item._status = SyncFileItem::NormalError; } else if (item._status != SyncFileItem::SoftError && item._hasBlacklistEntry && newEntry._ignoreDuration > 0) { item._status = SyncFileItem::BlacklistedError; } - qCInfo(lcPropagator) << "blacklisting " << item._file - << " for " << newEntry._ignoreDuration - << ", retry count " << newEntry._retryCount; + qCInfo(lcPropagator) << "blacklisting " << item.localName() << " for " << newEntry._ignoreDuration << ", retry count " << newEntry._retryCount; } void PropagateItemJob::done(SyncFileItem::Status statusArg, const QString &errorString) @@ -269,9 +266,9 @@ void PropagateItemJob::done(SyncFileItem::Status statusArg, const QString &error case SyncFileItem::Restoration: if (_item->_hasBlacklistEntry) { // wipe blacklist entry. - propagator()->_journal->wipeErrorBlacklistEntry(_item->_file); + propagator()->_journal->wipeErrorBlacklistEntry(_item->localName()); // remove a blacklist entry in case the file was moved. - if (_item->_originalFile != _item->_file) { + if (_item->_originalFile != _item->localName()) { propagator()->_journal->wipeErrorBlacklistEntry(_item->_originalFile); } } @@ -443,7 +440,7 @@ void OwncloudPropagator::start(SyncFileItemSet &&items) for (const auto &item : std::as_const(items)) { // First check if this is an item in a directory which is going to be removed. - if (currentRemoveDirectoryJob && FileSystem::isChildPathOf(item->_file, currentRemoveDirectoryJob->path())) { + if (currentRemoveDirectoryJob && FileSystem::isChildPathOf(item->localName(), currentRemoveDirectoryJob->path())) { // Check the sync instruction for the item: if (item->instruction() == CSYNC_INSTRUCTION_REMOVE) { // already taken care of. (by the removal of the parent directory) @@ -466,7 +463,7 @@ void OwncloudPropagator::start(SyncFileItemSet &&items) continue; } else if (item->instruction() != CSYNC_INSTRUCTION_RENAME) { // all is good, the rename will be executed before the directory deletion - qCWarning(lcPropagator) << "WARNING: Job within a removed directory? This should not happen!" << item->_file << item->instruction(); + qCWarning(lcPropagator) << "WARNING: Job within a removed directory? This should not happen!" << item->localName() << item->instruction(); Q_ASSERT(false); // we shouldn't land here, but assert for debug purposes } } @@ -477,7 +474,7 @@ void OwncloudPropagator::start(SyncFileItemSet &&items) if (!maybeConflictDirectory.isEmpty()) { if (FileSystem::isChildPathOf(item->destination(), maybeConflictDirectory)) { // We're processing an item in a CONFLICT directory. - qCInfo(lcPropagator) << "Skipping job inside CONFLICT directory" << item->_file << item->instruction(); + qCInfo(lcPropagator) << "Skipping job inside CONFLICT directory" << item->localName() << item->instruction(); item->setInstruction(CSYNC_INSTRUCTION_NONE); continue; } else { @@ -549,7 +546,7 @@ void OwncloudPropagator::start(SyncFileItemSet &&items) if (item->instruction() == CSYNC_INSTRUCTION_CONFLICT) { // This might be a file or a directory on the local side. If it's a // directory we want to skip processing items inside it. - maybeConflictDirectory = item->_file; + maybeConflictDirectory = item->localName(); } } } @@ -746,15 +743,14 @@ OwncloudPropagator::DiskSpaceResult OwncloudPropagator::diskSpaceCheck() const bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item, PropagatorCompositeJob *composite, QString *error) { - QString fn = fullLocalPath(item->_file); + QString fn = fullLocalPath(item->localName()); QString renameError; auto conflictModTime = FileSystem::getModTime(fn); QString conflictUserName; if (account()->capabilities().uploadConflictFiles()) conflictUserName = account()->davDisplayName(); - QString conflictFileName = Utility::makeConflictFileName( - item->_file, Utility::qDateTimeFromTime_t(conflictModTime), conflictUserName); + QString conflictFileName = Utility::makeConflictFileName(item->localName(), Utility::qDateTimeFromTime_t(conflictModTime), conflictUserName); QString conflictFilePath = fullLocalPath(conflictFileName); // If the file is locked, we want to retry this sync when it @@ -778,7 +774,7 @@ bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item, ConflictRecord conflictRecord; conflictRecord.path = conflictFileName.toUtf8(); conflictRecord.baseModtime = item->_previousModtime; - conflictRecord.initialBasePath = item->_file.toUtf8(); + conflictRecord.initialBasePath = item->localName().toUtf8(); SyncJournalFileRecord baseRecord; if (_journal->getFileRecord(item->_originalFile, &baseRecord) && baseRecord.isValid()) { @@ -794,7 +790,7 @@ bool OwncloudPropagator::createConflict(const SyncFileItemPtr &item, if (account()->capabilities().uploadConflictFiles()) { if (composite && !QFileInfo(conflictFilePath).isDir()) { SyncFileItemPtr conflictItem = SyncFileItemPtr(new SyncFileItem); - conflictItem->_file = conflictFileName; + conflictItem->setLocalName(conflictFileName); conflictItem->_type = ItemTypeFile; conflictItem->_direction = SyncFileItem::Up; conflictItem->setInstruction(CSYNC_INSTRUCTION_NEW); @@ -823,7 +819,7 @@ Result OwncloudPropagator::updatePlace if (item._type == ItemTypeVirtualFileDehydration) { // when dehydrating the file must not be pinned // don't use destinatio() with suffix placeholder - const auto pin = syncOptions()._vfs->pinState(item._file); + const auto pin = syncOptions()._vfs->pinState(item.localName()); if (pin && pin.get() == PinState::AlwaysLocal) { return false; } @@ -843,7 +839,7 @@ Result OwncloudPropagator::updateMetad auto record = item.toSyncJournalFileRecordWithInode(fsPath); if (result.get() == Vfs::ConvertToPlaceholderResult::Locked) { record._hasDirtyPlaceholder = true; - Q_EMIT seenLockedFile(fullLocalPath(item._file), FileSystem::LockMode::Exclusive); + Q_EMIT seenLockedFile(fullLocalPath(item.localName()), FileSystem::LockMode::Exclusive); } const auto dBresult = _journal->setFileRecord(record); if (!dBresult) { @@ -1126,7 +1122,7 @@ void PropagateDirectory::slotSubJobsFinished(const SyncFileItem::Status status) _item->_status = SyncFileItem::Success; const auto result = propagator()->updateMetadata(*_item); if (!result) { - qCWarning(lcDirectory) << "Error writing to the database for file" << _item->_file << "with" << result.error(); + qCWarning(lcDirectory) << "Error writing to the database for file" << _item->localName() << "with" << result.error(); done(SyncFileItem::FatalError, tr("Error updating metadata: %1").arg(result.error())); return; } else if (result.get() == Vfs::ConvertToPlaceholderResult::Locked) { @@ -1154,7 +1150,7 @@ void PropagateDirectory::slotSubJobsFinished(const SyncFileItem::Status status) PropagateRootDirectory::PropagateRootDirectory(OwncloudPropagator *propagator) : PropagateDirectory(propagator, SyncFileItemPtr([] { auto f = new SyncFileItem; - f->_file = QLatin1Char('/'); + f->setLocalName(QStringLiteral("/")); return f; }())) , _dirDeletionJobs(propagator, path()) @@ -1301,8 +1297,7 @@ void OCC::PropagateUpdateMetaDataJob::start() const QString filePath = propagator()->fullLocalPath(_item->destination()); if (_item->_direction == SyncFileItem::Down) { SyncJournalFileRecord prev; - if (propagator()->_journal->getFileRecord(_item->_file, &prev) - && prev.isValid()) { + if (propagator()->_journal->getFileRecord(_item->localName(), &prev) && prev.isValid()) { if (_item->_checksumHeader.isEmpty()) { _item->_checksumHeader = prev._checksumHeader; } @@ -1314,7 +1309,7 @@ void OCC::PropagateUpdateMetaDataJob::start() done(SyncFileItem::FatalError, tr("Could not update file : %1").arg(result.error())); return; } else if (result.get() == Vfs::ConvertToPlaceholderResult::Locked) { - done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(_item->_file)); + done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(_item->localName())); return; } done(SyncFileItem::Success); diff --git a/src/libsync/progressdispatcher.cpp b/src/libsync/progressdispatcher.cpp index 572144318ce..84a526d197d 100644 --- a/src/libsync/progressdispatcher.cpp +++ b/src/libsync/progressdispatcher.cpp @@ -44,7 +44,7 @@ QString Progress::asResultString(const SyncFileItem &item) case CSYNC_INSTRUCTION_REMOVE: return QCoreApplication::translate("progress", "Deleted"); case CSYNC_INSTRUCTION_RENAME: - return QCoreApplication::translate("progress", "%1 moved to %2").arg(item._file, item._renameTarget); + return QCoreApplication::translate("progress", "%1 moved to %2").arg(item.localName(), item._renameTarget); case CSYNC_INSTRUCTION_IGNORE: return QCoreApplication::translate("progress", "Ignored"); case CSYNC_INSTRUCTION_ERROR: @@ -185,14 +185,14 @@ void ProgressInfo::updateTotalsForFile(const SyncFileItem &item, qint64 newSize) return; } - if (!_currentItems.contains(item._file)) { + if (!_currentItems.contains(item.localName())) { _sizeProgress._total += newSize - item._size; } else { - _sizeProgress._total += newSize - _currentItems[item._file]._progress._total; + _sizeProgress._total += newSize - _currentItems[item.localName()]._progress._total; } setProgressItem(item, 0); - _currentItems[item._file]._progress._total = newSize; + _currentItems[item.localName()]._progress._total = newSize; } qint64 ProgressInfo::totalFiles() const @@ -228,9 +228,9 @@ void ProgressInfo::setProgressComplete(const SyncFileItem &item) _fileProgress.setCompleted(_fileProgress._completed + item._affectedItems); if (ProgressInfo::isSizeDependent(item)) { - _totalSizeOfCompletedJobs += _currentItems[item._file]._progress._total; + _totalSizeOfCompletedJobs += _currentItems[item.localName()]._progress._total; } - _currentItems.remove(item._file); + _currentItems.remove(item.localName()); recomputeCompletedSize(); _lastCompletedItem = item; } @@ -241,11 +241,11 @@ void ProgressInfo::setProgressItem(const SyncFileItem &item, qint64 completed) return; } - if (!_currentItems.contains(item._file)) { - _currentItems[item._file]._item = item; - _currentItems[item._file]._progress._total = item._size; + if (!_currentItems.contains(item.localName())) { + _currentItems[item.localName()]._item = item; + _currentItems[item.localName()]._progress._total = item._size; } - _currentItems[item._file]._progress.setCompleted(completed); + _currentItems[item.localName()]._progress.setCompleted(completed); recomputeCompletedSize(); // This seems dubious! @@ -329,7 +329,7 @@ bool ProgressInfo::trustEta() const ProgressInfo::Estimates ProgressInfo::fileProgress(const SyncFileItem &item) const { - return _currentItems[item._file]._progress.estimates(); + return _currentItems[item.localName()]._progress.estimates(); } void ProgressInfo::updateEstimates() diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index a0ffb440a4f..aa5d2d280a8 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -420,7 +420,7 @@ void PropagateDownloadFile::start() auto &vfs = syncOptions._vfs; - const QString fsPath = propagator()->fullLocalPath(_item->_file); + const QString fsPath = propagator()->fullLocalPath(_item->localName()); // For virtual files just dehydrate or create the file and be done if (_item->_type == ItemTypeVirtualFileDehydration) { if (FileSystem::fileChanged(QFileInfo{fsPath}, _item->_previousSize, _item->_previousModtime)) { @@ -433,12 +433,12 @@ void PropagateDownloadFile::start() done(SyncFileItem::SoftError, tr("Failed to free up space, the file %1 is currently in use").arg(fsPath)); return; } - qCDebug(lcPropagateDownload) << "dehydrating file" << _item->_file; + qCDebug(lcPropagateDownload) << "dehydrating file" << _item->localName(); updateMetadata(false); return; } if (vfs->mode() == Vfs::Off && _item->_type == ItemTypeVirtualFile) { - qCWarning(lcPropagateDownload) << "ignored virtual file type of" << _item->_file; + qCWarning(lcPropagateDownload) << "ignored virtual file type of" << _item->localName(); _item->_type = ItemTypeFile; } @@ -454,8 +454,10 @@ void PropagateDownloadFile::start() if (_item->_type == ItemTypeVirtualFile) { qCDebug(lcPropagateDownload) << "creating virtual file" << _item; // do a klaas' case clash check. - if (auto clash = propagator()->localFileNameClash(_item->_file)) { - done(SyncFileItem::NormalError, tr("File %1 can not be downloaded because of a local file name clash with %2!").arg(QDir::toNativeSeparators(_item->_file), QDir::toNativeSeparators(clash.get()))); + if (auto clash = propagator()->localFileNameClash(_item->localName())) { + done(SyncFileItem::NormalError, + tr("File %1 can not be downloaded because of a local file name clash with %2!") + .arg(QDir::toNativeSeparators(_item->localName()), QDir::toNativeSeparators(clash.get()))); return; } const bool isConflict = _item->instruction() == CSYNC_INSTRUCTION_CONFLICT && QFileInfo(fsPath).isDir(); @@ -494,14 +496,14 @@ void PropagateDownloadFile::start() if (_item->instruction() == CSYNC_INSTRUCTION_CONFLICT && _item->_size == _item->_previousSize && !_item->_checksumHeader.isEmpty() && (csync_is_collision_safe_hash(_item->_checksumHeader) || _item->_modtime == _item->_previousModtime)) { - qCDebug(lcPropagateDownload) << _item->_file << "may not need download, computing checksum"; + qCDebug(lcPropagateDownload) << _item->localName() << "may not need download, computing checksum"; auto computeChecksum = new ComputeChecksum(this); const auto checksumHeader = ChecksumHeader::parseChecksumHeader(_item->_checksumHeader); computeChecksum->setChecksumType(checksumHeader.type()); connect(computeChecksum, &ComputeChecksum::done, this, &PropagateDownloadFile::conflictChecksumComputed); propagator()->_activeJobList.append(this); - computeChecksum->start(propagator()->fullLocalPath(_item->_file)); + computeChecksum->start(propagator()->fullLocalPath(_item->localName())); return; } @@ -514,11 +516,11 @@ void PropagateDownloadFile::conflictChecksumComputed(CheckSums::Algorithm checks const auto checksumHeader = ChecksumHeader::parseChecksumHeader(_item->_checksumHeader); if (checksumHeader == ChecksumHeader(checksumType, checksum)) { // No download necessary, just update fs and journal metadata - qCDebug(lcPropagateDownload) << _item->_file << "remote and local checksum match"; + qCDebug(lcPropagateDownload) << _item->localName() << "remote and local checksum match"; // Apply the server mtime locally if necessary, ensuring the journal // and local mtimes end up identical - auto fn = propagator()->fullLocalPath(_item->_file); + auto fn = propagator()->fullLocalPath(_item->localName()); if (_item->_modtime != _item->_previousModtime) { FileSystem::setModTime(fn, _item->_modtime); } @@ -535,27 +537,29 @@ void PropagateDownloadFile::startDownload() return; // do a klaas' case clash check. - if (auto clash = propagator()->localFileNameClash(_item->_file)) { - done(SyncFileItem::NormalError, tr("File %1 can not be downloaded because of a local file name clash with %2!").arg(QDir::toNativeSeparators(_item->_file), QDir::toNativeSeparators(clash.get()))); + if (auto clash = propagator()->localFileNameClash(_item->localName())) { + done(SyncFileItem::NormalError, + tr("File %1 can not be downloaded because of a local file name clash with %2!") + .arg(QDir::toNativeSeparators(_item->localName()), QDir::toNativeSeparators(clash.get()))); return; } // If the file is locked, we want to retry this sync when it // becomes available again - const auto targetFile = propagator()->fullLocalPath(_item->_file); + const auto targetFile = propagator()->fullLocalPath(_item->localName()); if (FileSystem::isFileLocked(targetFile, FileSystem::LockMode::Exclusive)) { Q_EMIT propagator()->seenLockedFile(targetFile, FileSystem::LockMode::Exclusive); - done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(QDir::toNativeSeparators(_item->_file))); + done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(QDir::toNativeSeparators(_item->localName()))); return; } propagator()->reportProgress(*_item, 0); QString tmpFileName; - const SyncJournalDb::DownloadInfo progressInfo = propagator()->_journal->getDownloadInfo(_item->_file); + const SyncJournalDb::DownloadInfo progressInfo = propagator()->_journal->getDownloadInfo(_item->localName()); if (progressInfo._valid) { // if the etag has changed meanwhile, remove the already downloaded part. if (progressInfo._etag != _item->_etag.toUtf8()) { FileSystem::remove(propagator()->fullLocalPath(progressInfo._tmpfile)); - propagator()->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo()); + propagator()->_journal->setDownloadInfo(_item->localName(), SyncJournalDb::DownloadInfo()); } else { tmpFileName = progressInfo._tmpfile; _expectedEtagForResume = QString::fromUtf8(progressInfo._etag); @@ -563,7 +567,7 @@ void PropagateDownloadFile::startDownload() } if (tmpFileName.isEmpty()) { - tmpFileName = createDownloadTmpFileName(_item->_file); + tmpFileName = createDownloadTmpFileName(_item->localName()); } _tmpFile.setFileName(propagator()->fullLocalPath(tmpFileName)); @@ -614,7 +618,7 @@ void PropagateDownloadFile::startDownload() pi._etag = _item->_etag.toUtf8(); pi._tmpfile = tmpFileName; pi._valid = true; - propagator()->_journal->setDownloadInfo(_item->_file, pi); + propagator()->_journal->setDownloadInfo(_item->localName(), pi); propagator()->_journal->commit(QStringLiteral("download file start")); } @@ -627,12 +631,11 @@ void PropagateDownloadFile::startFullDownload() if (_item->_directDownloadUrl.isEmpty()) { // Normal job, download from oC instance - _job = new GETFileJob(propagator()->account(), propagator()->webDavUrl(), - propagator()->fullRemotePath(_item->_file), - &_tmpFile, headers, _expectedEtagForResume, _resumeStart, this); + _job = new GETFileJob(propagator()->account(), propagator()->webDavUrl(), propagator()->fullRemotePath(_item->localName()), &_tmpFile, headers, + _expectedEtagForResume, _resumeStart, this); } else { // We were provided a direct URL, use that one - qCInfo(lcPropagateDownload) << "directDownloadUrl given for " << _item->_file << _item->_directDownloadUrl; + qCInfo(lcPropagateDownload) << "directDownloadUrl given for " << _item->localName() << _item->_directDownloadUrl; if (!_item->_directDownloadCookies.isEmpty()) { headers["Cookie"] = _item->_directDownloadCookies.toUtf8(); @@ -701,7 +704,7 @@ void PropagateDownloadFile::slotGetFinished() if (_tmpFile.exists() && (_tmpFile.size() == 0 || badRangeHeader || fileNotFound)) { _tmpFile.close(); FileSystem::remove(_tmpFile.fileName()); - propagator()->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo()); + propagator()->_journal->setDownloadInfo(_item->localName(), SyncJournalDb::DownloadInfo()); } if (!_item->_directDownloadUrl.isEmpty() && err != QNetworkReply::OperationCanceledError) { @@ -730,7 +733,7 @@ void PropagateDownloadFile::slotGetFinished() // As a precaution against bugs that cause our database and the // reality on the server to diverge, rediscover this folder on the // next sync run. - propagator()->_journal->schedulePathForRemoteDiscovery(_item->_file); + propagator()->_journal->schedulePathForRemoteDiscovery(_item->localName()); } QByteArray errorBody; @@ -809,7 +812,7 @@ void PropagateDownloadFile::slotGetFinished() // it might still be downloaded in a parallel job and not exist in // the database yet!) if (job->reply()->rawHeader("OC-Conflict") == "1") { - _conflictRecord.path = _item->_file.toUtf8(); + _conflictRecord.path = _item->localName().toUtf8(); _conflictRecord.initialBasePath = job->reply()->rawHeader("OC-ConflictInitialBasePath"); _conflictRecord.baseFileId = job->reply()->rawHeader("OC-ConflictBaseFileId"); _conflictRecord.baseEtag = job->reply()->rawHeader("OC-ConflictBaseEtag"); @@ -847,7 +850,7 @@ void PropagateDownloadFile::slotChecksumFail(const QString &errMsg) void PropagateDownloadFile::deleteExistingFolder() { - QString existingDir = propagator()->fullLocalPath(_item->_file); + QString existingDir = propagator()->fullLocalPath(_item->localName()); if (!QFileInfo(existingDir).isDir()) { return; } @@ -903,8 +906,10 @@ void PropagateDownloadFile::downloadFinished() // In case of file name clash, report an error // This can happen if another parallel download saved a clashing file. - if (auto clash = propagator()->localFileNameClash(_item->_file)) { - done(SyncFileItem::NormalError, tr("File %1 cannot be saved because of a local file name clash with %2!").arg(QDir::toNativeSeparators(_item->_file), QDir::toNativeSeparators(clash.get()))); + if (auto clash = propagator()->localFileNameClash(_item->localName())) { + done(SyncFileItem::NormalError, + tr("File %1 cannot be saved because of a local file name clash with %2!") + .arg(QDir::toNativeSeparators(_item->localName()), QDir::toNativeSeparators(clash.get()))); return; } @@ -928,7 +933,7 @@ void PropagateDownloadFile::downloadFinished() done(SyncFileItem::NormalError, result.error()); return; } else if (result.get() == Vfs::ConvertToPlaceholderResult::Locked) { - done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(_item->_file)); + done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(_item->localName())); return; } } @@ -990,7 +995,7 @@ void PropagateDownloadFile::downloadFinished() // If the virtual file used to have a different name and db // entry, remove it transfer its old pin state. if (_item->_type == ItemTypeVirtualFileDownload) { - const QString virtualFile = _item->_file + vfs->fileSuffix(); + const QString virtualFile = _item->localName() + vfs->fileSuffix(); const QString virtualFileAbsPath = propagator()->fullLocalPath(virtualFile); qCDebug(lcPropagateDownload) << "Download of previous virtual file finished" << virtualFileAbsPath; if (QFileInfo::exists(virtualFileAbsPath)) { @@ -1003,15 +1008,15 @@ void PropagateDownloadFile::downloadFinished() // Move the pin state to the new location auto pin = propagator()->_journal->internalPinStates().rawForPath(virtualFile.toUtf8()); if (pin && *pin != PinState::Inherited) { - std::ignore = vfs->setPinState(_item->_file, *pin); + std::ignore = vfs->setPinState(_item->localName(), *pin); std::ignore = vfs->setPinState(virtualFile, PinState::Inherited); } } // Ensure the pin state isn't contradictory - auto pin = vfs->pinState(_item->_file); + auto pin = vfs->pinState(_item->localName()); if (pin && *pin == PinState::OnlineOnly) { - std::ignore = vfs->setPinState(_item->_file, PinState::Unspecified); + std::ignore = vfs->setPinState(_item->localName(), PinState::Unspecified); } } @@ -1025,10 +1030,10 @@ void PropagateDownloadFile::updateMetadata(bool isConflict) done(SyncFileItem::FatalError, tr("Error updating metadata: %1").arg(result.error())); return; } else if (result.get() == Vfs::ConvertToPlaceholderResult::Locked) { - done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(_item->_file)); + done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(_item->localName())); return; } - propagator()->_journal->setDownloadInfo(_item->_file, SyncJournalDb::DownloadInfo()); + propagator()->_journal->setDownloadInfo(_item->localName(), SyncJournalDb::DownloadInfo()); propagator()->_journal->commit(QStringLiteral("download file start2")); done(isConflict ? SyncFileItem::Conflict : SyncFileItem::Success); @@ -1036,7 +1041,7 @@ void PropagateDownloadFile::updateMetadata(bool isConflict) // handle the special recall file if (Q_UNLIKELY(Theme::instance()->enableCernBranding())) { if (!_item->_remotePerm.hasPermission(RemotePermissions::IsShared) - && (_item->_file == QLatin1String(".sys.admin#recall#") || _item->_file.endsWith(QLatin1String("/.sys.admin#recall#")))) { + && (_item->localName() == QLatin1String(".sys.admin#recall#") || _item->localName().endsWith(QLatin1String("/.sys.admin#recall#")))) { const QString fn = propagator()->fullLocalPath(_item->destination()); CernRecallFeature::handleRecallFile(fn, propagator()->localPath(), *propagator()->_journal); } @@ -1044,7 +1049,8 @@ void PropagateDownloadFile::updateMetadata(bool isConflict) const auto duration = std::chrono::milliseconds(_stopwatch.elapsed()); if (isLikelyFinishedQuickly() && duration > 5s) { - qCWarning(lcPropagateDownload) << "WARNING: Unexpectedly slow connection, took" << duration.count() << "ms for" << _item->_size - _resumeStart << "bytes for" << _item->_file; + qCWarning(lcPropagateDownload) << "WARNING: Unexpectedly slow connection, took" << duration.count() << "ms for" << _item->_size - _resumeStart + << "bytes for" << _item->localName(); } } diff --git a/src/libsync/propagateremotedelete.cpp b/src/libsync/propagateremotedelete.cpp index 11eff0c3b7a..74be9690ec6 100644 --- a/src/libsync/propagateremotedelete.cpp +++ b/src/libsync/propagateremotedelete.cpp @@ -46,11 +46,9 @@ void PropagateRemoteDelete::start() if (propagator()->_abortRequested) return; - qCDebug(lcPropagateRemoteDelete) << _item->_file; + qCDebug(lcPropagateRemoteDelete) << _item->localName(); - _job = new DeleteJob(propagator()->account(), propagator()->webDavUrl(), - propagator()->fullRemotePath(_item->_file), - this); + _job = new DeleteJob(propagator()->account(), propagator()->webDavUrl(), propagator()->fullRemotePath(_item->localName()), this); connect(_job.data(), &DeleteJob::finishedSignal, this, &PropagateRemoteDelete::slotDeleteJobFinished); propagator()->_activeJobList.append(this); _job->start(); diff --git a/src/libsync/propagateremotemkdir.cpp b/src/libsync/propagateremotemkdir.cpp index d497c6ec5e6..34757b08fa1 100644 --- a/src/libsync/propagateremotemkdir.cpp +++ b/src/libsync/propagateremotemkdir.cpp @@ -37,7 +37,7 @@ void PropagateRemoteMkdir::start() if (propagator()->_abortRequested) return; - qCDebug(lcPropagateRemoteMkdir) << _item->_file; + qCDebug(lcPropagateRemoteMkdir) << _item->localName(); propagator()->_activeJobList.append(this); @@ -45,9 +45,7 @@ void PropagateRemoteMkdir::start() return slotStartMkcolJob(); } - _job = new DeleteJob(propagator()->account(), propagator()->webDavUrl(), - propagator()->fullRemotePath(_item->_file), - this); + _job = new DeleteJob(propagator()->account(), propagator()->webDavUrl(), propagator()->fullRemotePath(_item->localName()), this); connect(qobject_cast(_job), &DeleteJob::finishedSignal, this, &PropagateRemoteMkdir::slotStartMkcolJob); _job->start(); } @@ -57,11 +55,9 @@ void PropagateRemoteMkdir::slotStartMkcolJob() if (propagator()->_abortRequested) return; - qCDebug(lcPropagateRemoteMkdir) << _item->_file; + qCDebug(lcPropagateRemoteMkdir) << _item->localName(); - _job = new MkColJob(propagator()->account(), propagator()->webDavUrl(), - propagator()->fullRemotePath(_item->_file), {}, - this); + _job = new MkColJob(propagator()->account(), propagator()->webDavUrl(), propagator()->fullRemotePath(_item->localName()), {}, this); connect(qobject_cast(_job), &MkColJob::finishedWithError, this, &PropagateRemoteMkdir::slotMkcolJobFinished); connect(qobject_cast(_job), &MkColJob::finishedWithoutError, this, &PropagateRemoteMkdir::slotMkcolJobFinished); _job->start(); diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp index 3c59b61f949..d769d762850 100644 --- a/src/libsync/propagateremotemove.cpp +++ b/src/libsync/propagateremotemove.cpp @@ -59,7 +59,7 @@ void PropagateRemoteMove::start() if (propagator()->_abortRequested) return; - QString origin = propagator()->adjustRenamedPath(_item->_file); + QString origin = propagator()->adjustRenamedPath(_item->localName()); qCDebug(lcPropagateRemoteMove) << origin << _item->_renameTarget; if (origin == _item->_renameTarget) { // The parent has been renamed already so there is nothing more to do. @@ -205,7 +205,7 @@ void PropagateRemoteMove::finalize() done(SyncFileItem::FatalError, tr("Error updating metadata: %1").arg(result.error())); return; } else if (result.get() == Vfs::ConvertToPlaceholderResult::Locked) { - done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(newItem._file)); + done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(newItem.localName())); return; } if (pinState && *pinState != PinState::Inherited @@ -215,8 +215,8 @@ void PropagateRemoteMove::finalize() } if (_item->isDirectory()) { - propagator()->_renamedDirectories.insert(_item->_file, _item->_renameTarget); - if (!adjustSelectiveSync(propagator()->_journal, _item->_file, _item->_renameTarget)) { + propagator()->_renamedDirectories.insert(_item->localName(), _item->_renameTarget); + if (!adjustSelectiveSync(propagator()->_journal, _item->localName(), _item->_renameTarget)) { done(SyncFileItem::FatalError, tr("Error writing metadata to the database")); return; } diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp index b73ded9e5a4..877909b5428 100644 --- a/src/libsync/propagateupload.cpp +++ b/src/libsync/propagateupload.cpp @@ -121,14 +121,15 @@ void PropagateUploadFileCommon::start() } // Check if the specific file can be accessed - if (propagator()->hasCaseClashAccessibilityProblem(_item->_file)) { - done(SyncFileItem::NormalError, tr("File %1 cannot be uploaded because another file with the same name, differing only in case, exists").arg(QDir::toNativeSeparators(_item->_file))); + if (propagator()->hasCaseClashAccessibilityProblem(_item->localName())) { + done(SyncFileItem::NormalError, + tr("File %1 cannot be uploaded because another file with the same name, differing only in case, exists") + .arg(QDir::toNativeSeparators(_item->localName()))); return; } // Check if we believe that the upload will fail due to remote quota limits - const qint64 quotaGuess = propagator()->_folderQuota.value( - QFileInfo(_item->_file).path(), std::numeric_limits::max()); + const qint64 quotaGuess = propagator()->_folderQuota.value(QFileInfo(_item->localName()).path(), std::numeric_limits::max()); if (_item->_size > quotaGuess) { // Necessary for blacklisting logic _item->_httpErrorCode = 507; @@ -143,9 +144,7 @@ void PropagateUploadFileCommon::start() return slotComputeContentChecksum(); } - auto job = new DeleteJob(propagator()->account(), propagator()->webDavUrl(), - propagator()->fullRemotePath(_item->_file), - this); + auto job = new DeleteJob(propagator()->account(), propagator()->webDavUrl(), propagator()->fullRemotePath(_item->localName()), this); addChildJob(job); connect(job, &DeleteJob::finishedSignal, this, &PropagateUploadFileCommon::slotComputeContentChecksum); job->start(); @@ -157,7 +156,7 @@ void PropagateUploadFileCommon::slotComputeContentChecksum() return; } - const QString filePath = propagator()->fullLocalPath(_item->_file); + const QString filePath = propagator()->fullLocalPath(_item->localName()); // remember the modtime before checksumming to be able to detect a file // change during the checksum calculation @@ -202,7 +201,7 @@ void PropagateUploadFileCommon::slotComputeTransmissionChecksum(CheckSums::Algor return; } - const QString filePath = propagator()->fullLocalPath(_item->_file); + const QString filePath = propagator()->fullLocalPath(_item->localName()); // we must be able to read the file if (FileSystem::isFileLocked(filePath, FileSystem::LockMode::SharedRead)) { Q_EMIT propagator()->seenLockedFile(filePath, FileSystem::LockMode::SharedRead); @@ -238,7 +237,7 @@ void PropagateUploadFileCommon::slotStartUpload(CheckSums::Algorithm transmissio _item->_checksumHeader = _transmissionChecksumHeader; } - const QString fullFilePath = propagator()->fullLocalPath(_item->_file); + const QString fullFilePath = propagator()->fullLocalPath(_item->localName()); if (!FileSystem::fileExists(fullFilePath)) { done(SyncFileItem::SoftError, tr("File Removed")); @@ -430,18 +429,16 @@ void PropagateUploadFileCommon::checkResettingErrors() { if (_item->_httpErrorCode == 412 || propagator()->account()->capabilities().httpErrorCodesThatResetFailingChunkedUploads().contains(_item->_httpErrorCode)) { - auto uploadInfo = propagator()->_journal->getUploadInfo(_item->_file); + auto uploadInfo = propagator()->_journal->getUploadInfo(_item->localName()); uploadInfo._errorCount += 1; if (uploadInfo._errorCount > 3) { - qCInfo(lcPropagateUpload) << "Reset transfer of" << _item->_file - << "due to repeated error" << _item->_httpErrorCode; + qCInfo(lcPropagateUpload) << "Reset transfer of" << _item->localName() << "due to repeated error" << _item->_httpErrorCode; uploadInfo = SyncJournalDb::UploadInfo(); } else { - qCInfo(lcPropagateUpload) << "Error count for maybe-reset error" << _item->_httpErrorCode - << "on file" << _item->_file - << "is" << uploadInfo._errorCount; + qCInfo(lcPropagateUpload) << "Error count for maybe-reset error" << _item->_httpErrorCode << "on file" << _item->localName() << "is" + << uploadInfo._errorCount; } - propagator()->_journal->setUploadInfo(_item->_file, uploadInfo); + propagator()->_journal->setUploadInfo(_item->localName(), uploadInfo); propagator()->_journal->commit(QStringLiteral("Upload info")); } } @@ -457,7 +454,7 @@ void PropagateUploadFileCommon::commonErrorHandling(AbstractNetworkJob *job) // Maybe the bad etag is in the database, we need to clear the // parent folder etag so we won't read from DB next sync. - propagator()->_journal->schedulePathForRemoteDiscovery(_item->_file); + propagator()->_journal->schedulePathForRemoteDiscovery(_item->localName()); propagator()->_anotherSyncNeeded = true; } @@ -470,7 +467,7 @@ void PropagateUploadFileCommon::commonErrorHandling(AbstractNetworkJob *job) // Insufficient remote storage. if (_item->_httpErrorCode == 507) { // Update the quota expectation - const auto path = QFileInfo(_item->_file).path(); + const auto path = QFileInfo(_item->localName()).path(); auto quotaIt = propagator()->_folderQuota.find(path); if (quotaIt != propagator()->_folderQuota.end()) { quotaIt.value() = qMin(quotaIt.value(), _item->_size - 1); @@ -501,7 +498,7 @@ void PropagateUploadFileCommon::adjustLastJobTimeout(AbstractNetworkJob *job, qi // This function is used whenever there is an error occuring and jobs might be in progress void PropagateUploadFileCommon::abortWithError(SyncFileItem::Status status, const QString &error) { - qCWarning(lcPropagateUpload) << Q_FUNC_INFO << _item->_file << error; + qCWarning(lcPropagateUpload) << Q_FUNC_INFO << _item->localName() << error; if (!_aborting) { abort(AbortType::Synchronous); done(status, error); @@ -524,7 +521,7 @@ QMap PropagateUploadFileCommon::headers() headers[QByteArrayLiteral("Content-Type")] = QByteArrayLiteral("application/octet-stream"); headers[QByteArrayLiteral("X-OC-Mtime")] = QByteArray::number(qint64(_item->_modtime)); - if (Q_UNLIKELY(Theme::instance()->enableCernBranding() && _item->_file.contains(QLatin1String(".sys.admin#recall#")))) { + if (Q_UNLIKELY(Theme::instance()->enableCernBranding() && _item->localName().contains(QLatin1String(".sys.admin#recall#")))) { // This is a file recall triggered by the admin. Note: the // recall list file created by the admin and downloaded by the // client (.sys.admin#recall#) also falls into this category @@ -544,7 +541,7 @@ QMap PropagateUploadFileCommon::headers() } // Set up a conflict file header pointing to the original file - auto conflictRecord = propagator()->_journal->conflictRecord(_item->_file.toUtf8()); + auto conflictRecord = propagator()->_journal->conflictRecord(_item->localName().toUtf8()); if (conflictRecord.isValid()) { headers[QByteArrayLiteral("OC-Conflict")] = "1"; if (!conflictRecord.initialBasePath.isEmpty()) @@ -566,7 +563,7 @@ void PropagateUploadFileCommon::finalize() // Update the quota, if known if (!_quotaUpdated) { - auto quotaIt = propagator()->_folderQuota.find(QFileInfo(_item->_file).path()); + auto quotaIt = propagator()->_folderQuota.find(QFileInfo(_item->localName()).path()); if (quotaIt != propagator()->_folderQuota.end()) { quotaIt.value() -= _item->_size; } @@ -574,9 +571,9 @@ void PropagateUploadFileCommon::finalize() } if (_item->_remotePerm.isNull()) { - qCWarning(lcPropagateUpload) << "PropagateUploadFileCommon::finalize: Missing permissions for" << propagator()->fullRemotePath(_item->_file); - auto *permCheck = - new PropfindJob(propagator()->account(), propagator()->webDavUrl(), propagator()->fullRemotePath(_item->_file), PropfindJob::Depth::Zero, this); + qCWarning(lcPropagateUpload) << "PropagateUploadFileCommon::finalize: Missing permissions for" << propagator()->fullRemotePath(_item->localName()); + auto *permCheck = new PropfindJob( + propagator()->account(), propagator()->webDavUrl(), propagator()->fullRemotePath(_item->localName()), PropfindJob::Depth::Zero, this); addChildJob(permCheck); permCheck->setProperties({ "http://owncloud.org/ns:permissions" }); connect(permCheck, &PropfindJob::directoryListingIterated, this, [this](const QString &, const QMap &map) { @@ -601,14 +598,14 @@ void PropagateUploadFileCommon::finalize() // even if their parent folder is online-only. if (_item->instruction() & (CSYNC_INSTRUCTION_NEW | CSYNC_INSTRUCTION_TYPE_CHANGE)) { auto &vfs = propagator()->syncOptions()._vfs; - const auto pin = vfs->pinState(_item->_file); + const auto pin = vfs->pinState(_item->localName()); if (pin && *pin == PinState::OnlineOnly) { - std::ignore = vfs->setPinState(_item->_file, PinState::Unspecified); + std::ignore = vfs->setPinState(_item->localName(), PinState::Unspecified); } } // Remove from the progress database: - propagator()->_journal->setUploadInfo(_item->_file, SyncJournalDb::UploadInfo()); + propagator()->_journal->setUploadInfo(_item->localName(), SyncJournalDb::UploadInfo()); propagator()->_journal->commit(QStringLiteral("upload file start")); done(SyncFileItem::Success); diff --git a/src/libsync/propagateuploadng.cpp b/src/libsync/propagateuploadng.cpp index 6e895a0aa41..52b0acb7b1b 100644 --- a/src/libsync/propagateuploadng.cpp +++ b/src/libsync/propagateuploadng.cpp @@ -84,7 +84,7 @@ PropagateUploadFileNG::PropagateUploadFileNG(OwncloudPropagator *propagator, con } void PropagateUploadFileNG::doStartUpload() { - const QString fileName = propagator()->fullLocalPath(_item->_file); + const QString fileName = propagator()->fullLocalPath(_item->localName()); // If the file is currently locked, we want to retry the sync // when it becomes available again. if (FileSystem::isFileLocked(fileName, FileSystem::LockMode::SharedRead)) { @@ -104,7 +104,7 @@ void PropagateUploadFileNG::doStartUpload() void PropagateUploadFileNG::doStartUploadNext() { - const SyncJournalDb::UploadInfo progressInfo = propagator()->_journal->getUploadInfo(_item->_file); + const SyncJournalDb::UploadInfo progressInfo = propagator()->_journal->getUploadInfo(_item->localName()); if (progressInfo.isChunked() && progressInfo.validate(_item->_size, _item->_modtime, _item->_checksumHeader)) { _transferId = progressInfo._transferid; auto job = new PropfindJob(propagator()->account(), propagator()->account()->url(), chunkPath(), PropfindJob::Depth::One, this); @@ -186,9 +186,8 @@ void PropagateUploadFileNG::slotPropfindFinished() if (_sent > _bytesToUpload) { // Normally this can't happen because the size is xor'ed with the transfer id, and it is // therefore impossible that there is more data on the server than on the file. - qCCritical(lcPropagateUploadNG) << "Inconsistency while resuming " << _item->_file - << ": the size on the server (" << _sent << ") is bigger than the size of the file (" - << _item->_size << ")"; + qCCritical(lcPropagateUploadNG) << "Inconsistency while resuming " << _item->localName() << ": the size on the server (" << _sent + << ") is bigger than the size of the file (" << _item->_size << ")"; // Wipe the old chunking data. // Fire and forget. Any error will be ignored. @@ -199,7 +198,7 @@ void PropagateUploadFileNG::slotPropfindFinished() return; } - qCInfo(lcPropagateUploadNG) << "Resuming " << _item->_file << "; sent =" << _sent << "; total=" << _bytesToUpload; + qCInfo(lcPropagateUploadNG) << "Resuming " << _item->localName() << "; sent =" << _sent << "; total=" << _bytesToUpload; if (!_serverChunks.isEmpty()) { qCInfo(lcPropagateUploadNG) << "To Delete" << _serverChunks.keys(); @@ -287,7 +286,7 @@ void PropagateUploadFileNG::startNewUpload() auto pi = _item->toUploadInfo(); pi._transferid = _transferId; - propagator()->_journal->setUploadInfo(_item->_file, pi); + propagator()->_journal->setUploadInfo(_item->localName(), pi); propagator()->_journal->commit(QStringLiteral("Upload info")); QMap headers; headers["OC-Total-Length"] = QByteArray::number(_item->_size); @@ -329,8 +328,7 @@ void PropagateUploadFileNG::doFinalMove() _finished = true; // Finish with a MOVE - QString destination = QDir::cleanPath(propagator()->webDavUrl().path() - + propagator()->fullRemotePath(_item->_file)); + QString destination = QDir::cleanPath(propagator()->webDavUrl().path() + propagator()->fullRemotePath(_item->localName())); auto headers = PropagateUploadFileCommon::headers(); // "If-Match applies to the source, but we are interested in comparing the etag of the destination @@ -371,7 +369,7 @@ void PropagateUploadFileNG::startNextChunk() _currentChunkOffset = _rangesToUpload.first().start; _currentChunkSize = qMin(propagator()->_chunkSize, _rangesToUpload.first().size); - const QString fileName = propagator()->fullLocalPath(_item->_file); + const QString fileName = propagator()->fullLocalPath(_item->localName()); auto device = std::make_unique(fileName, _currentChunkOffset, _currentChunkSize, propagator()->_bandwidthManager); if (!device->open(QIODevice::ReadOnly)) { @@ -455,7 +453,7 @@ void PropagateUploadFileNG::slotPutFinished() _finished = _sent == _bytesToUpload; // Check if the file still exists - const QString fullFilePath(propagator()->fullLocalPath(_item->_file)); + const QString fullFilePath(propagator()->fullLocalPath(_item->localName())); if (!FileSystem::fileExists(fullFilePath)) { if (!_finished) { abortWithError(SyncFileItem::SoftError, tr("The local file was removed during sync.")); @@ -477,14 +475,14 @@ void PropagateUploadFileNG::slotPutFinished() if (!_finished) { // Deletes an existing blacklist entry on successful chunk upload if (_item->_hasBlacklistEntry) { - propagator()->_journal->wipeErrorBlacklistEntry(_item->_file); + propagator()->_journal->wipeErrorBlacklistEntry(_item->localName()); _item->_hasBlacklistEntry = false; } // Reset the error count on successful chunk upload - auto uploadInfo = propagator()->_journal->getUploadInfo(_item->_file); + auto uploadInfo = propagator()->_journal->getUploadInfo(_item->localName()); uploadInfo._errorCount = 0; - propagator()->_journal->setUploadInfo(_item->_file, uploadInfo); + propagator()->_journal->setUploadInfo(_item->localName(), uploadInfo); propagator()->_journal->commit(QStringLiteral("Upload info")); } startNextChunk(); @@ -516,7 +514,7 @@ void PropagateUploadFileNG::slotMoveJobFinished() QByteArray fid = job->reply()->rawHeader("OC-FileID"); if (fid.isEmpty()) { - qCWarning(lcPropagateUploadNG) << "Server did not return a OC-FileID" << _item->_file; + qCWarning(lcPropagateUploadNG) << "Server did not return a OC-FileID" << _item->localName(); abortWithError(SyncFileItem::NormalError, tr("Missing File ID from server")); return; } else { @@ -529,7 +527,7 @@ void PropagateUploadFileNG::slotMoveJobFinished() _item->_etag = getEtagFromReply(job->reply()); if (_item->_etag.isEmpty()) { - qCWarning(lcPropagateUploadNG) << "Server did not return an ETAG" << _item->_file; + qCWarning(lcPropagateUploadNG) << "Server did not return an ETAG" << _item->localName(); abortWithError(SyncFileItem::NormalError, tr("Missing ETag from server")); return; } diff --git a/src/libsync/propagateuploadtus.cpp b/src/libsync/propagateuploadtus.cpp index edc22ba96ee..746bbb334cb 100644 --- a/src/libsync/propagateuploadtus.cpp +++ b/src/libsync/propagateuploadtus.cpp @@ -52,7 +52,7 @@ Q_LOGGING_CATEGORY(lcPropagateUploadTUS, "sync.propagator.upload.tus", QtDebugMs UploadDevice *PropagateUploadFileTUS::prepareDevice(const quint64 &chunkSize) { - const QString localFileName = propagator()->fullLocalPath(_item->_file); + const QString localFileName = propagator()->fullLocalPath(_item->localName()); // If the file is currently locked, we want to retry the sync // when it becomes available again. if (FileSystem::isFileLocked(localFileName, FileSystem::LockMode::SharedRead)) { @@ -80,7 +80,7 @@ SimpleNetworkJob *PropagateUploadFileTUS::makeCreationWithUploadJob(QNetworkRequ QByteArrayList encodedMetaData; auto addMetaData = [&encodedMetaData](const QByteArray &key, const QByteArray &value) { encodedMetaData << key + ' ' + value.toBase64(); }; - addMetaData(QByteArrayLiteral("filename"), propagator()->fullRemotePath(_item->_file).toUtf8()); + addMetaData(QByteArrayLiteral("filename"), propagator()->fullRemotePath(_item->localName()).toUtf8()); // in difference to the old protocol the algrithm and the value are space seperated addMetaData(QByteArrayLiteral("checksum"), Utility::enumToString(checksumHeader.type()).toUtf8() + ' ' + checksumHeader.checksum()); addMetaData(QByteArrayLiteral("mtime"), QByteArray::number(static_cast(_item->_modtime))); @@ -119,7 +119,7 @@ void PropagateUploadFileTUS::doStartUpload() propagator()->reportProgress(*_item, 0); propagator()->_activeJobList.append(this); - const auto info = propagator()->_journal->getUploadInfo(_item->_file); + const auto info = propagator()->_journal->getUploadInfo(_item->localName()); if (info.validate(_item->_size, _item->_modtime, _item->_checksumHeader)) { _location = info._url; Q_ASSERT(_location.isValid()); @@ -152,11 +152,11 @@ void PropagateUploadFileTUS::startNextChunk() SimpleNetworkJob *job; if (_currentOffset != 0) { - qCDebug(lcPropagateUploadTUS) << "Starting to patch upload:" << propagator()->fullRemotePath(_item->_file); + qCDebug(lcPropagateUploadTUS) << "Starting to patch upload:" << propagator()->fullRemotePath(_item->localName()); job = new SimpleNetworkJob(propagator()->account(), _location, {}, "PATCH", device, req, this); } else { Q_ASSERT(_location.isEmpty()); - qCDebug(lcPropagateUploadTUS) << "Starting creation with upload:" << propagator()->fullRemotePath(_item->_file); + qCDebug(lcPropagateUploadTUS) << "Starting creation with upload:" << propagator()->fullRemotePath(_item->localName()); job = makeCreationWithUploadJob(&req, device); } @@ -179,7 +179,7 @@ void PropagateUploadFileTUS::slotChunkFinished() { SimpleNetworkJob *job = qobject_cast(sender()); Q_ASSERT(job); - qCDebug(lcPropagateUploadTUS) << propagator()->fullRemotePath(_item->_file) << HttpLogger::requestVerb(*job->reply()); + qCDebug(lcPropagateUploadTUS) << propagator()->fullRemotePath(_item->localName()) << HttpLogger::requestVerb(*job->reply()); _item->_httpErrorCode = job->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); _item->_responseTimeStamp = job->responseTimestamp(); @@ -190,7 +190,7 @@ void PropagateUploadFileTUS::slotChunkFinished() // try to get the offset if possible, only try once if (err == QNetworkReply::TimeoutError && !_location.isEmpty() && HttpLogger::requestVerb(*job->reply()) != "HEAD") { - qCWarning(lcPropagateUploadTUS) << propagator()->fullRemotePath(_item->_file) << "Encountered a timeout -> get progrss for" << _location; + qCWarning(lcPropagateUploadTUS) << propagator()->fullRemotePath(_item->localName()) << "Encountered a timeout -> get progrss for" << _location; QNetworkRequest req; setTusVersionHeader(req); auto updateJob = new SimpleNetworkJob(propagator()->account(), propagator()->webDavUrl(), _location.path(), "HEAD", {}, req, this); @@ -216,7 +216,7 @@ void PropagateUploadFileTUS::slotChunkFinished() _finished = offset == _item->_size; // Check if the file still exists - const QString fullFilePath(propagator()->fullLocalPath(_item->_file)); + const QString fullFilePath(propagator()->fullLocalPath(_item->localName())); if (!FileSystem::fileExists(fullFilePath)) { if (!_finished) { abortWithError(SyncFileItem::SoftError, tr("The local file was removed during sync.")); @@ -242,7 +242,7 @@ void PropagateUploadFileTUS::slotChunkFinished() // add the new location auto info = _item->toUploadInfo(); info._url = _location; - propagator()->_journal->setUploadInfo(_item->_file, info); + propagator()->_journal->setUploadInfo(_item->localName(), info); } startNextChunk(); return; @@ -259,7 +259,8 @@ void PropagateUploadFileTUS::slotChunkFinished() if (!_finished) { // Either the ETag or the remote Permissions were not in the headers of the reply. // Start a PROPFIND to fetch these data from the server. - auto check = new PropfindJob(propagator()->account(), propagator()->webDavUrl(), propagator()->fullRemotePath(_item->_file), PropfindJob::Depth::Zero, this); + auto check = new PropfindJob( + propagator()->account(), propagator()->webDavUrl(), propagator()->fullRemotePath(_item->localName()), PropfindJob::Depth::Zero, this); addChildJob(check); check->setProperties({ "http://owncloud.org/ns:fileid", "http://owncloud.org/ns:permissions", "getetag" }); connect(check, &PropfindJob::directoryListingIterated, this, [this](const QString &, const QMap &map) { diff --git a/src/libsync/propagateuploadv1.cpp b/src/libsync/propagateuploadv1.cpp index d11f003c6c1..286679e3fb3 100644 --- a/src/libsync/propagateuploadv1.cpp +++ b/src/libsync/propagateuploadv1.cpp @@ -34,7 +34,7 @@ namespace OCC { void PropagateUploadFileV1::doStartUpload() { - const QString fileName = propagator()->fullLocalPath(_item->_file); + const QString fileName = propagator()->fullLocalPath(_item->localName()); // If the file is currently locked, we want to retry the sync // when it becomes available again. if (FileSystem::isFileLocked(fileName, FileSystem::LockMode::SharedRead)) { @@ -51,12 +51,12 @@ void PropagateUploadFileV1::doStartUpload() _startChunk = 0; _transferId = uint(QRandomGenerator::global()->generate()) ^ uint(_item->_modtime) ^ (uint(_item->_size) << 16); - const SyncJournalDb::UploadInfo progressInfo = propagator()->_journal->getUploadInfo(_item->_file); + const SyncJournalDb::UploadInfo progressInfo = propagator()->_journal->getUploadInfo(_item->localName()); if (progressInfo.isChunked() && progressInfo.validate(_item->_size, _item->_modtime, _item->_checksumHeader)) { _startChunk = progressInfo._chunk; _transferId = progressInfo._transferid; - qCInfo(lcPropagateUploadV1) << _item->_file << ": Resuming from chunk " << _startChunk; + qCInfo(lcPropagateUploadV1) << _item->localName() << ": Resuming from chunk " << _startChunk; } else if (_chunkCount <= 1 && !_item->_checksumHeader.isEmpty()) { // If there is only one chunk, write the checksum in the database, so if the PUT is sent // to the server, but the connection drops before we get the etag, we can check the checksum @@ -65,7 +65,7 @@ void PropagateUploadFileV1::doStartUpload() pi._chunk = 0; pi._transferid = 0; // We set a null transfer id because it is not chunked. pi._errorCount = 0; - propagator()->_journal->setUploadInfo(_item->_file, pi); + propagator()->_journal->setUploadInfo(_item->localName(), pi); propagator()->_journal->commit(QStringLiteral("Upload info")); } @@ -93,7 +93,7 @@ void PropagateUploadFileV1::startNextChunk() headers[QByteArrayLiteral("OC-Total-Length")] = QByteArray::number(fileSize); headers[QByteArrayLiteral("OC-Chunk-Size")] = QByteArray::number(chunkSize()); - QString path = _item->_file; + QString path = _item->localName(); qint64 chunkStart = 0; qint64 currentChunkSize = fileSize; @@ -127,7 +127,7 @@ void PropagateUploadFileV1::startNextChunk() headers[checkSumHeaderC] = _transmissionChecksumHeader; } - const QString fileName = propagator()->fullLocalPath(_item->_file); + const QString fileName = propagator()->fullLocalPath(_item->localName()); auto device = std::make_unique(fileName, chunkStart, currentChunkSize, propagator()->_bandwidthManager); if (!device->open(QIODevice::ReadOnly)) { @@ -221,7 +221,7 @@ void PropagateUploadFileV1::slotPutFinished() _finished = etag.length() > 0; // Check if the file still exists - const QString fullFilePath(propagator()->fullLocalPath(_item->_file)); + const QString fullFilePath(propagator()->fullLocalPath(_item->localName())); if (!FileSystem::fileExists(fullFilePath)) { if (!_finished) { abortWithError(SyncFileItem::SoftError, tr("The local file was removed during sync.")); @@ -253,7 +253,7 @@ void PropagateUploadFileV1::slotPutFinished() // Deletes an existing blacklist entry on successful chunk upload if (_item->_hasBlacklistEntry) { - propagator()->_journal->wipeErrorBlacklistEntry(_item->_file); + propagator()->_journal->wipeErrorBlacklistEntry(_item->localName()); _item->_hasBlacklistEntry = false; } @@ -272,7 +272,7 @@ void PropagateUploadFileV1::slotPutFinished() pi._errorCount = 0; // successful chunk upload resets pi._contentChecksum = _item->_checksumHeader; pi._size = _item->_size; - propagator()->_journal->setUploadInfo(_item->_file, pi); + propagator()->_journal->setUploadInfo(_item->localName(), pi); propagator()->_journal->commit(QStringLiteral("Upload info")); startNextChunk(); return; diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index 4f77705789d..85d5ea4d484 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -100,10 +100,10 @@ void PropagateLocalRemove::start() if (propagator()->_abortRequested) return; - const QString filename = propagator()->fullLocalPath(_item->_file); + const QString filename = propagator()->fullLocalPath(_item->localName()); qCDebug(lcPropagateLocalRemove) << filename; - if (auto clash = propagator()->localFileNameClash(_item->_file)) { + if (auto clash = propagator()->localFileNameClash(_item->localName())) { done(SyncFileItem::NormalError, tr("Could not remove %1 because of a local file name clash with %2!").arg(QDir::toNativeSeparators(filename), QDir::toNativeSeparators(clash.get()))); return; } @@ -148,7 +148,7 @@ void PropagateLocalMkdir::start() if (propagator()->_abortRequested) return; - QDir newDir(propagator()->fullLocalPath(_item->_file)); + QDir newDir(propagator()->fullLocalPath(_item->localName())); QString newDirStr = QDir::toNativeSeparators(newDir.path()); // When turning something that used to be a file into a directory @@ -173,13 +173,13 @@ void PropagateLocalMkdir::start() } } - if (auto clash = propagator()->localFileNameClash(_item->_file)) { - qCWarning(lcPropagateLocalMkdir) << "New folder to create locally already exists with different case:" << _item->_file; + if (auto clash = propagator()->localFileNameClash(_item->localName())) { + qCWarning(lcPropagateLocalMkdir) << "New folder to create locally already exists with different case:" << _item->localName(); done(SyncFileItem::NormalError, tr("Can not create local folder %1 because of a local file name clash with %2").arg(newDirStr, QDir::toNativeSeparators(clash.get()))); return; } QDir localDir(propagator()->localPath()); - if (!localDir.mkpath(_item->_file)) { + if (!localDir.mkpath(_item->localName())) { done(SyncFileItem::NormalError, tr("could not create folder %1").arg(newDirStr)); return; } @@ -196,7 +196,7 @@ void PropagateLocalMkdir::start() done(SyncFileItem::FatalError, tr("Error updating metadata: %1").arg(result.error())); return; } else if (result.get() == Vfs::ConvertToPlaceholderResult::Locked) { - done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(newItem._file)); + done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(newItem.localName())); return; } propagator()->_journal->commit(QStringLiteral("localMkdir")); @@ -215,17 +215,16 @@ void PropagateLocalRename::start() if (propagator()->_abortRequested) return; - QString existingFile = propagator()->fullLocalPath(propagator()->adjustRenamedPath(_item->_file)); + QString existingFile = propagator()->fullLocalPath(propagator()->adjustRenamedPath(_item->localName())); 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. - if (_item->_file != _item->_renameTarget) { + if (_item->localName() != _item->_renameTarget) { propagator()->reportProgress(*_item, 0); qCDebug(lcPropagateLocalRename) << "MOVE " << existingFile << " => " << targetFile; - if (QString::compare(_item->_file, _item->_renameTarget, Qt::CaseInsensitive) != 0 - && propagator()->localFileNameClash(_item->_renameTarget)) { + if (QString::compare(_item->localName(), _item->_renameTarget, Qt::CaseInsensitive) != 0 && propagator()->localFileNameClash(_item->_renameTarget)) { // Only use localFileNameClash for the destination if we know that the source was not // the one conflicting (renaming A.txt -> a.txt is OK) @@ -233,8 +232,7 @@ void PropagateLocalRename::start() // it would have to come out the localFileNameClash function done(SyncFileItem::NormalError, tr("File %1 can not be renamed to %2 because of a local file name clash") - .arg(QDir::toNativeSeparators(_item->_file), - QDir::toNativeSeparators(_item->_renameTarget))); + .arg(QDir::toNativeSeparators(_item->localName()), QDir::toNativeSeparators(_item->_renameTarget))); return; } if (FileSystem::isFileLocked(existingFile, FileSystem::LockMode::Exclusive)) { @@ -257,7 +255,7 @@ void PropagateLocalRename::start() auto pinState = vfs->pinState(_item->_originalFile); std::ignore = vfs->setPinState(_item->_originalFile, PinState::Inherited); - const auto oldFile = _item->_file; + const auto oldFile = _item->localName(); if (!_item->isDirectory()) { // Directories are saved at the end SyncFileItem newItem(*_item); @@ -269,7 +267,7 @@ void PropagateLocalRename::start() done(SyncFileItem::FatalError, tr("Error updating metadata: %1").arg(result.error())); return; } else if (result.get() == Vfs::ConvertToPlaceholderResult::Locked) { - done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(newItem._file)); + done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(newItem.localName())); return; } } else { diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 848009c78a7..1421b5d4239 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -96,7 +96,7 @@ bool SyncEngine::checkErrorBlacklisting(SyncFileItem &item) return false; } - SyncJournalErrorBlacklistRecord entry = _journal->errorBlacklistEntry(item._file); + SyncJournalErrorBlacklistRecord entry = _journal->errorBlacklistEntry(item.localName()); item._hasBlacklistEntry = false; if (!entry.isValid()) { @@ -108,7 +108,7 @@ bool SyncEngine::checkErrorBlacklisting(SyncFileItem &item) // If duration has expired, it's not blacklisted anymore time_t now = Utility::qDateTimeToTime_t(QDateTime::currentDateTimeUtc()); if (now >= entry._lastTryTime + entry._ignoreDuration) { - qCInfo(lcEngine) << "blacklist entry for " << item._file << " has expired!"; + qCInfo(lcEngine) << "blacklist entry for " << item.localName() << " has expired!"; return false; } @@ -118,19 +118,19 @@ bool SyncEngine::checkErrorBlacklisting(SyncFileItem &item) if (item._modtime == 0 || entry._lastTryModtime == 0) { return false; } else if (item._modtime != entry._lastTryModtime) { - qCInfo(lcEngine) << item._file << " is blacklisted, but has changed mtime!"; + qCInfo(lcEngine) << item.localName() << " is blacklisted, but has changed mtime!"; return false; } else if (item._renameTarget != entry._renameTarget) { - qCInfo(lcEngine) << item._file << " is blacklisted, but rename target changed from" << entry._renameTarget; + qCInfo(lcEngine) << item.localName() << " is blacklisted, but rename target changed from" << entry._renameTarget; return false; } } else if (item._direction == SyncFileItem::Down) { // download, check the etag. if (item._etag.isEmpty() || entry._lastTryEtag.isEmpty()) { - qCInfo(lcEngine) << item._file << "one ETag is empty, no blacklisting"; + qCInfo(lcEngine) << item.localName() << "one ETag is empty, no blacklisting"; return false; } else if (item._etag.toUtf8() != entry._lastTryEtag) { - qCInfo(lcEngine) << item._file << " is blacklisted, but has changed etag!"; + qCInfo(lcEngine) << item.localName() << " is blacklisted, but has changed etag!"; return false; } } @@ -174,7 +174,7 @@ void SyncEngine::deleteStaleDownloadInfos(const SyncFileItemSet &syncItems) QSet download_file_paths; for (const auto &it : syncItems) { if (it->_direction == SyncFileItem::Down && it->_type == ItemTypeFile && isFileTransferInstruction(it->instruction())) { - download_file_paths.insert(it->_file); + download_file_paths.insert(it->localName()); } } @@ -194,7 +194,7 @@ void SyncEngine::deleteStaleUploadInfos(const SyncFileItemSet &syncItems) QSet upload_file_paths; for (const auto &it : syncItems) { if (it->_direction == SyncFileItem::Up && it->_type == ItemTypeFile && isFileTransferInstruction(it->instruction())) { - upload_file_paths.insert(it->_file); + upload_file_paths.insert(it->localName()); } } @@ -217,7 +217,7 @@ void SyncEngine::deleteStaleErrorBlacklistEntries(const SyncFileItemSet &syncIte QSet blacklist_file_paths; for (const auto &it : syncItems) { if (it->_hasBlacklistEntry) - blacklist_file_paths.insert(it->_file); + blacklist_file_paths.insert(it->localName()); } // Delete from journal. @@ -266,10 +266,10 @@ void SyncEngine::conflictRecordMaintenance() void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item) { - if (Utility::isConflictFile(item->_file)) - _seenConflictFiles.insert(item->_file); + if (Utility::isConflictFile(item->localName())) + _seenConflictFiles.insert(item->localName()); if (item->instruction() == CSYNC_INSTRUCTION_NONE) { - if (_account->capabilities().uploadConflictFiles() && Utility::isConflictFile(item->_file)) { + if (_account->capabilities().uploadConflictFiles() && Utility::isConflictFile(item->localName())) { // For uploaded conflict files, files with no action performed on them should // be displayed: but we mustn't overwrite the instruction if something happens // to the file! @@ -289,7 +289,7 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item) const auto it = _syncItems.find(item); if (it != _syncItems.cend()) { const auto &item2 = it->get(); - qCWarning(lcEngine) << "We already have an item for " << item2->_file << ":" << item2->instruction() << item2->_direction << "|" + qCWarning(lcEngine) << "We already have an item for " << item2->localName() << ":" << item2->instruction() << item2->_direction << "|" << item->instruction() << item->_direction; return false; } @@ -300,7 +300,7 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item) slotNewItem(item); if (item->isDirectory()) { - slotFolderDiscovered(item->_etag.isEmpty(), item->_file); + slotFolderDiscovered(item->_etag.isEmpty(), item->localName()); } } @@ -526,11 +526,11 @@ void SyncEngine::slotDiscoveryFinished() if (regex.isValid()) { QSet names; for (auto &i : _syncItems) { - if (regex.match(i->_file).hasMatch()) { + if (regex.match(i->localName()).hasMatch()) { int index = -1; QStringView ref; do { - ref = QStringView(i->_file).mid(0, index); + ref = QStringView(i->localName()).mid(0, index); names.insert(ref); index = ref.lastIndexOf(QLatin1Char('/')); } while (index > 0); @@ -549,7 +549,7 @@ void SyncEngine::slotDiscoveryFinished() } return old_size - c.size(); }; - erase_if(_syncItems, [&names](const SyncFileItemPtr &i) { return !names.contains(QStringView{i->_file}); }); + erase_if(_syncItems, [&names](const SyncFileItemPtr &i) { return !names.contains(QStringView{i->localName()}); }); } qCInfo(lcEngine) << "#### Reconcile (aboutToPropagate) ####################################################" << _duration.duration(); @@ -713,11 +713,11 @@ void SyncEngine::restoreOldFiles(SyncFileItemSet &syncItems) switch ((*it)->instruction()) { case CSYNC_INSTRUCTION_SYNC: - qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << (*it)->_file; + qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << (*it)->localName(); (*it)->setInstruction(CSYNC_INSTRUCTION_CONFLICT); break; case CSYNC_INSTRUCTION_REMOVE: - qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << (*it)->_file; + qCWarning(lcEngine) << "restoreOldFiles: RESTORING" << (*it)->localName(); (*it)->setInstruction(CSYNC_INSTRUCTION_NEW); (*it)->_direction = SyncFileItem::Up; break; diff --git a/src/libsync/syncfileitem.cpp b/src/libsync/syncfileitem.cpp index 59842b71b8a..fbe7dfad833 100644 --- a/src/libsync/syncfileitem.cpp +++ b/src/libsync/syncfileitem.cpp @@ -62,7 +62,7 @@ SyncJournalFileRecord SyncFileItem::toSyncJournalFileRecordWithInode(const QStri SyncFileItemPtr SyncFileItem::fromSyncJournalFileRecord(const SyncJournalFileRecord &rec) { auto item = SyncFileItemPtr::create(); - item->_file = QString::fromUtf8(rec._path); + item->_localName = QString::fromUtf8(rec._path); item->_inode = rec._inode; item->_modtime = rec._modtime; item->_type = rec._type; @@ -132,7 +132,7 @@ QDebug operator<<(QDebug debug, const OCC::SyncFileItem *item) } else { QDebugStateSaver saver(debug); debug.setAutoInsertSpaces(false); - debug << "OCC::SyncFileItem(file=" << item->_file; + debug << "OCC::SyncFileItem(file=" << item->localName(); if (!item->_renameTarget.isEmpty()) { debug << ", destination=" << item->destination(); } diff --git a/src/libsync/syncfileitem.h b/src/libsync/syncfileitem.h index 9b9cfeb0cc2..6f65fc0279b 100644 --- a/src/libsync/syncfileitem.h +++ b/src/libsync/syncfileitem.h @@ -141,8 +141,9 @@ class OWNCLOUDSYNC_EXPORT SyncFileItem static SyncFileItemPtr fromSyncJournalFileRecord(const SyncJournalFileRecord &rec); - SyncFileItem() - : _type(ItemTypeSkip) + SyncFileItem(const QString &localName = {}) + : _localName(localName) + , _type(ItemTypeSkip) , _direction(None) , _serverHasIgnoredFiles(false) , _hasBlacklistEntry(false) @@ -204,13 +205,10 @@ class OWNCLOUDSYNC_EXPORT SyncFileItem if (!_renameTarget.isEmpty()) { return _renameTarget; } - return _file; + return localName(); } - bool isEmpty() const - { - return _file.isEmpty(); - } + bool isEmpty() const { return localName().isEmpty(); } bool isDirectory() const { @@ -246,14 +244,19 @@ class OWNCLOUDSYNC_EXPORT SyncFileItem && !(_instruction == CSYNC_INSTRUCTION_CONFLICT && _status == SyncFileItem::Success); } - // Variables useful for everybody + QString localName() const { return _localName; } + void setLocalName(const QString &newName) { _localName = newName; } +private: /** The syncfolder-relative filesystem path that the operation is about * * For rename operation this is the rename source and the target is in _renameTarget. */ - QString _file; + QString _localName; + // QString _remoteName; + +public: /** for renames: the name _file should be renamed to * for dehydrations: the name _file should become after dehydration (like adding a suffix) * otherwise empty. Use destination() to find the sync target. diff --git a/src/libsync/syncresult.cpp b/src/libsync/syncresult.cpp index f33be635a75..19ef2da5d0b 100644 --- a/src/libsync/syncresult.cpp +++ b/src/libsync/syncresult.cpp @@ -112,7 +112,7 @@ void SyncResult::processCompletedItem(const SyncFileItemPtr &item) // Process the item to the gui if (item->_status == SyncFileItem::FatalError || item->_status == SyncFileItem::NormalError) { //: this displays an error string (%2) for a file %1 - appendErrorString(QObject::tr("%1: %2").arg(item->_file, item->_errorString)); + appendErrorString(QObject::tr("%1: %2").arg(item->localName(), item->_errorString)); _numErrorItems++; if (!_firstItemError) { _firstItemError = item; diff --git a/src/plugins/vfs/suffix/vfs_suffix.cpp b/src/plugins/vfs/suffix/vfs_suffix.cpp index 70a46033a1c..09081d46959 100644 --- a/src/plugins/vfs/suffix/vfs_suffix.cpp +++ b/src/plugins/vfs/suffix/vfs_suffix.cpp @@ -68,19 +68,19 @@ Result VfsSuffix::updateMetadata(const { if (item._type == ItemTypeVirtualFileDehydration) { SyncFileItem virtualItem(item); - virtualItem._file = item._renameTarget; + virtualItem.setLocalName(item._renameTarget); auto r = createPlaceholder(virtualItem); if (!r) { return r.error(); } // Move the item's pin state - auto pin = params().journal->internalPinStates().rawForPath(item._file.toUtf8()); + auto pin = params().journal->internalPinStates().rawForPath(item.localName().toUtf8()); if (pin && *pin != PinState::Inherited) { std::ignore = setPinState(item._renameTarget, *pin); } - if (item._file != item._renameTarget) { // can be the same when renaming foo -> foo.owncloud to dehydrate + if (item.localName() != item._renameTarget) { // can be the same when renaming foo -> foo.owncloud to dehydrate QString error; - if (!FileSystem::remove(params().filesystemPath + item._file, &error)) { + if (!FileSystem::remove(params().filesystemPath + item.localName(), &error)) { return error; } } @@ -100,7 +100,7 @@ Result VfsSuffix::updateMetadata(const Result VfsSuffix::createPlaceholder(const SyncFileItem &item) { // The concrete shape of the placeholder is also used in isDehydratedPlaceholder() below - const QString fn = params().filesystemPath + item._file; + const QString fn = params().filesystemPath + item.localName(); Q_ASSERT(fn.endsWith(fileSuffix())); QFile file(fn); diff --git a/test/modeltests/testprotocolmodel.cpp b/test/modeltests/testprotocolmodel.cpp index 760349be662..c6879f0a7cc 100644 --- a/test/modeltests/testprotocolmodel.cpp +++ b/test/modeltests/testprotocolmodel.cpp @@ -52,14 +52,14 @@ private Q_SLOTS: std::vector tmp; tmp.reserve(size); for (size_t i = 0; i < size; ++i) { - item->_file = QString::number(i); + item->setLocalName(QString::number(i)); tmp.emplace_back(foo, item); } model->reset(std::move(tmp)); // test some inserts for (int i = 0; i < 5; ++i) { - item->_file = QString::number(i); + item->setLocalName(QString::number(i)); model->addProtocolItem(ProtocolItem { bar, item }); } diff --git a/test/testchunkingng.cpp b/test/testchunkingng.cpp index 01c21cd00f4..ab4599ce6ac 100644 --- a/test/testchunkingng.cpp +++ b/test/testchunkingng.cpp @@ -267,15 +267,15 @@ private Q_SLOTS: auto checkIsUpdateMetaData = [&](const SyncFileItemSet &items) { QCOMPARE(items.size(), 2); auto it = items.cbegin(); - QCOMPARE(it->get()->_file, QLatin1String("A")); + QCOMPARE(it->get()->localName(), QLatin1String("A")); QCOMPARE(it->get()->instruction(), CSYNC_INSTRUCTION_UPDATE_METADATA); it++; - QCOMPARE(it->get()->_file, QLatin1String("A/a0")); + QCOMPARE(it->get()->localName(), QLatin1String("A/a0")); QCOMPARE(it->get()->instruction(), CSYNC_INSTRUCTION_UPDATE_METADATA); QCOMPARE(it->get()->_etag, QString::fromUtf8(fakeFolder.remoteModifier().find(QStringLiteral("A/a0"))->etag)); }; auto checkEtagUpdated = [&](const SyncFileItemPtr &item) { - if (item->_file == QLatin1String("A/a0")) { + if (item->localName() == QLatin1String("A/a0")) { SyncJournalFileRecord record; QVERIFY(fakeFolder.syncJournal().getFileRecord(QByteArray("A/a0"), &record)); QCOMPARE(record._etag, fakeFolder.remoteModifier().find(QStringLiteral("A/a0"))->etag); diff --git a/test/testsyncengine.cpp b/test/testsyncengine.cpp index 1279830b7b1..9a3836b215a 100644 --- a/test/testsyncengine.cpp +++ b/test/testsyncengine.cpp @@ -339,12 +339,12 @@ private Q_SLOTS: QSet seen; for(const QList &args : completeSpy) { auto item = args[0].value(); - qDebug() << item->_file << item->isDirectory() << item->_status; - QVERIFY(!seen.contains(item->_file)); // signal only sent once per item - seen.insert(item->_file); - if (item->_file == QLatin1String("Y/Z/d2")) { + qDebug() << item->localName() << item->isDirectory() << item->_status; + QVERIFY(!seen.contains(item->localName())); // signal only sent once per item + seen.insert(item->localName()); + if (item->localName() == QLatin1String("Y/Z/d2")) { QVERIFY(item->_status == SyncFileItem::NormalError); - } else if (item->_file == QLatin1String("Y/Z/d3")) { + } else if (item->localName() == QLatin1String("Y/Z/d3")) { QVERIFY(item->_status != SyncFileItem::Success); } else if (!item->isDirectory()) { QVERIFY(item->_status == SyncFileItem::Success); @@ -493,11 +493,11 @@ private Q_SLOTS: connect(&fakeFolder.syncEngine(), &SyncEngine::aboutToPropagate, [&](const SyncFileItemSet &items) { SyncFileItemPtr a1, b1, c1; for (auto &item : items) { - if (item->_file == QLatin1String("A/a1")) + if (item->localName() == QLatin1String("A/a1")) a1 = item; - if (item->_file == QLatin1String("B/b1")) + if (item->localName() == QLatin1String("B/b1")) b1 = item; - if (item->_file == QLatin1String("C/c1")) + if (item->localName() == QLatin1String("C/c1")) c1 = item; } diff --git a/test/testsyncfileitem.cpp b/test/testsyncfileitem.cpp index d99416860e8..ae0c619969b 100644 --- a/test/testsyncfileitem.cpp +++ b/test/testsyncfileitem.cpp @@ -21,29 +21,23 @@ private Q_SLOTS: void cleanupTestCase() { } - SyncFileItem createItem( const QString& file ) { - SyncFileItem i; - i._file = file; - return i; - } - void testComparator_data() { QTest::addColumn("a"); QTest::addColumn("b"); QTest::addColumn("c"); - QTest::newRow("a1") << createItem(QStringLiteral("client")) << createItem(QStringLiteral("client/build")) << createItem(QStringLiteral("client-build")); - QTest::newRow("a2") << createItem(QStringLiteral("test/t1")) << createItem(QStringLiteral("test/t2")) << createItem(QStringLiteral("test/t3")); - QTest::newRow("a3") << createItem(QStringLiteral("ABCD")) << createItem(QStringLiteral("abcd")) << createItem(QStringLiteral("zzzz")); + QTest::newRow("a1") << SyncFileItem(QStringLiteral("client")) << SyncFileItem(QStringLiteral("client/build")) + << SyncFileItem(QStringLiteral("client-build")); + QTest::newRow("a2") << SyncFileItem(QStringLiteral("test/t1")) << SyncFileItem(QStringLiteral("test/t2")) << SyncFileItem(QStringLiteral("test/t3")); + QTest::newRow("a3") << SyncFileItem(QStringLiteral("ABCD")) << SyncFileItem(QStringLiteral("abcd")) << SyncFileItem(QStringLiteral("zzzz")); - SyncFileItem movedItem1; - movedItem1._file = QStringLiteral("folder/source/file.f"); + SyncFileItem movedItem1(QStringLiteral("folder/source/file.f")); movedItem1._renameTarget = QStringLiteral("folder/destination/file.f"); movedItem1.setInstruction(CSYNC_INSTRUCTION_RENAME); - QTest::newRow("move1") << createItem(QStringLiteral("folder/destination")) << movedItem1 << createItem(QStringLiteral("folder/destination-2")); - QTest::newRow("move2") << createItem(QStringLiteral("folder/destination/1")) << movedItem1 << createItem(QStringLiteral("folder/source")); - QTest::newRow("move3") << createItem(QStringLiteral("abc")) << movedItem1 << createItem(QStringLiteral("ijk")); + QTest::newRow("move1") << SyncFileItem(QStringLiteral("folder/destination")) << movedItem1 << SyncFileItem(QStringLiteral("folder/destination-2")); + QTest::newRow("move2") << SyncFileItem(QStringLiteral("folder/destination/1")) << movedItem1 << SyncFileItem(QStringLiteral("folder/source")); + QTest::newRow("move3") << SyncFileItem(QStringLiteral("abc")) << movedItem1 << SyncFileItem(QStringLiteral("ijk")); } void testComparator() { diff --git a/test/testsyncmove.cpp b/test/testsyncmove.cpp index 0c41b6360ae..9133f4c506b 100644 --- a/test/testsyncmove.cpp +++ b/test/testsyncmove.cpp @@ -397,9 +397,9 @@ private Q_SLOTS: QCOMPARE(counter.nDELETE, 0); QVERIFY(itemSuccessfulMove(completeSpy, QStringLiteral("A/a1m"))); QVERIFY(itemSuccessfulMove(completeSpy, QStringLiteral("B/b1m"))); - QCOMPARE(completeSpy.findItem(QStringLiteral("A/a1m"))->_file, QStringLiteral("A/a1")); + QCOMPARE(completeSpy.findItem(QStringLiteral("A/a1m"))->localName(), QStringLiteral("A/a1")); QCOMPARE(completeSpy.findItem(QStringLiteral("A/a1m"))->_renameTarget, QStringLiteral("A/a1m")); - QCOMPARE(completeSpy.findItem(QStringLiteral("B/b1m"))->_file, QStringLiteral("B/b1")); + QCOMPARE(completeSpy.findItem(QStringLiteral("B/b1m"))->localName(), QStringLiteral("B/b1")); QCOMPARE(completeSpy.findItem(QStringLiteral("B/b1m"))->_renameTarget, QStringLiteral("B/b1m")); counter.reset(); } @@ -552,9 +552,9 @@ private Q_SLOTS: QCOMPARE(counter.nDELETE, 0); QVERIFY(itemSuccessfulMove(completeSpy, QStringLiteral("AM"))); QVERIFY(itemSuccessfulMove(completeSpy, QStringLiteral("BM"))); - QCOMPARE(completeSpy.findItem(QStringLiteral("AM"))->_file, QStringLiteral("A")); + QCOMPARE(completeSpy.findItem(QStringLiteral("AM"))->localName(), QStringLiteral("A")); QCOMPARE(completeSpy.findItem(QStringLiteral("AM"))->_renameTarget, QStringLiteral("AM")); - QCOMPARE(completeSpy.findItem(QStringLiteral("BM"))->_file, QStringLiteral("B")); + QCOMPARE(completeSpy.findItem(QStringLiteral("BM"))->localName(), QStringLiteral("B")); QCOMPARE(completeSpy.findItem(QStringLiteral("BM"))->_renameTarget, QStringLiteral("BM")); counter.reset(); } diff --git a/test/testsyncvirtualfiles.cpp b/test/testsyncvirtualfiles.cpp index 1f837b6067d..81ee8588aca 100644 --- a/test/testsyncvirtualfiles.cpp +++ b/test/testsyncvirtualfiles.cpp @@ -825,7 +825,7 @@ private Q_SLOTS: QVERIFY(hasDehydratedDbEntries(QStringLiteral("A/a1"))); QCOMPARE(itemInstruction(completeSpy, QStringLiteral("A/a1") + Theme::instance()->appDotVirtualFileSuffix()), CSYNC_INSTRUCTION_SYNC); QCOMPARE(completeSpy.findItem(QStringLiteral("A/a1") + Theme::instance()->appDotVirtualFileSuffix())->_type, ItemTypeVirtualFileDehydration); - QCOMPARE(completeSpy.findItem(QStringLiteral("A/a1") + Theme::instance()->appDotVirtualFileSuffix())->_file, QStringLiteral("A/a1")); + QCOMPARE(completeSpy.findItem(QStringLiteral("A/a1") + Theme::instance()->appDotVirtualFileSuffix())->localName(), QStringLiteral("A/a1")); QCOMPARE(completeSpy.findItem(QStringLiteral("A/a1") + Theme::instance()->appDotVirtualFileSuffix())->_renameTarget, QStringLiteral("A/a1") + Theme::instance()->appDotVirtualFileSuffix()); QVERIFY(isDehydrated(QStringLiteral("A/a2")));