diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index f5374b257..961e8754c 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -840,10 +840,10 @@ void Folder::slotTransmissionProgress(const ProgressInfo &pi) void Folder::slotItemCompleted(const SyncFileItemPtr &item) { // add new directories or remove gone away dirs to the watcher - if (item->_isDirectory && item->_instruction == CSYNC_INSTRUCTION_NEW) { + if (item->isDirectory() && item->_instruction == CSYNC_INSTRUCTION_NEW) { FolderMan::instance()->addMonitorPath(alias(), path() + item->_file); } - if (item->_isDirectory && item->_instruction == CSYNC_INSTRUCTION_REMOVE) { + if (item->isDirectory() && item->_instruction == CSYNC_INSTRUCTION_REMOVE) { FolderMan::instance()->removeMonitorPath(alias(), path() + item->_file); } diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 7550838e7..7af77926c 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -291,7 +291,7 @@ bool PropagateItemJob::checkForProblemsWithShared(int httpStatusCode, const QStr PropagateItemJob *newJob = NULL; if (httpStatusCode == 403 && propagator()->isInSharedDirectory(_item->_file)) { - if (!_item->_isDirectory) { + if (!_item->isDirectory()) { SyncFileItemPtr downloadItem(new SyncFileItem(*_item)); if (downloadItem->_instruction == CSYNC_INSTRUCTION_NEW || downloadItem->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE) { @@ -363,7 +363,7 @@ PropagateItemJob *OwncloudPropagator::createJob(const SyncFileItemPtr &item) return new PropagateRemoteDelete(this, item); case CSYNC_INSTRUCTION_NEW: case CSYNC_INSTRUCTION_TYPE_CHANGE: - if (item->_isDirectory) { + if (item->isDirectory()) { if (item->_direction == SyncFileItem::Down) { auto job = new PropagateLocalMkdir(this, item); job->setDeleteExistingFile(deleteExisting); @@ -439,7 +439,7 @@ void OwncloudPropagator::start(const SyncFileItemVector &items) delDirJob->increaseAffectedCount(); } continue; - } else if (item->_isDirectory + } else if (item->isDirectory() && (item->_instruction == CSYNC_INSTRUCTION_NEW || item->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE)) { // create a new directory within a deleted directory? That can happen if the directory @@ -463,7 +463,7 @@ void OwncloudPropagator::start(const SyncFileItemVector &items) directories.pop(); } - if (item->_isDirectory) { + if (item->isDirectory()) { PropagateDirectory *dir = new PropagateDirectory(this, item); if (item->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE diff --git a/src/libsync/progressdispatcher.h b/src/libsync/progressdispatcher.h index f7015f6c5..b51be9810 100644 --- a/src/libsync/progressdispatcher.h +++ b/src/libsync/progressdispatcher.h @@ -103,7 +103,7 @@ public: /** Return true if the size needs to be taken in account in the total amount of time */ static inline bool isSizeDependent(const SyncFileItem &item) { - return !item._isDirectory && (item._instruction == CSYNC_INSTRUCTION_CONFLICT + return !item.isDirectory() && (item._instruction == CSYNC_INSTRUCTION_CONFLICT || item._instruction == CSYNC_INSTRUCTION_SYNC || item._instruction == CSYNC_INSTRUCTION_NEW || item._instruction == CSYNC_INSTRUCTION_TYPE_CHANGE); diff --git a/src/libsync/propagateremotedelete.cpp b/src/libsync/propagateremotedelete.cpp index d66cb2d91..73f5c8240 100644 --- a/src/libsync/propagateremotedelete.cpp +++ b/src/libsync/propagateremotedelete.cpp @@ -120,7 +120,7 @@ void PropagateRemoteDelete::slotDeleteJobFinished() return; } - propagator()->_journal->deleteFileRecord(_item->_originalFile, _item->_isDirectory); + propagator()->_journal->deleteFileRecord(_item->_originalFile, _item->isDirectory()); propagator()->_journal->commit("Remote Remove"); done(SyncFileItem::Success); } diff --git a/src/libsync/propagateremotedelete.h b/src/libsync/propagateremotedelete.h index c4367b3ac..6246f7cbf 100644 --- a/src/libsync/propagateremotedelete.h +++ b/src/libsync/propagateremotedelete.h @@ -54,7 +54,7 @@ public: void start() Q_DECL_OVERRIDE; void abort() Q_DECL_OVERRIDE; - bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return !_item->_isDirectory; } + bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return !_item->isDirectory(); } private slots: void slotDeleteJobFinished(); diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp index 69979b1a9..a45736564 100644 --- a/src/libsync/propagateremotemove.cpp +++ b/src/libsync/propagateremotemove.cpp @@ -187,7 +187,7 @@ void PropagateRemoteMove::finalize() return; } - if (_item->_isDirectory) { + if (_item->isDirectory()) { if (!adjustSelectiveSync(propagator()->_journal, _item->_file, _item->_renameTarget)) { done(SyncFileItem::FatalError, tr("Error writing metadata to the database")); return; diff --git a/src/libsync/propagateremotemove.h b/src/libsync/propagateremotemove.h index 3180712df..bf6661a65 100644 --- a/src/libsync/propagateremotemove.h +++ b/src/libsync/propagateremotemove.h @@ -57,7 +57,7 @@ public: } void start() Q_DECL_OVERRIDE; void abort() Q_DECL_OVERRIDE; - JobParallelism parallelism() Q_DECL_OVERRIDE { return _item->_isDirectory ? WaitForFinished : FullParallelism; } + JobParallelism parallelism() Q_DECL_OVERRIDE { return _item->isDirectory() ? WaitForFinished : FullParallelism; } /** * Rename the directory in the selective sync list diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index 769408dfb..de9339996 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -121,7 +121,7 @@ void PropagateLocalRemove::start() return; } - if (_item->_isDirectory) { + if (_item->isDirectory()) { if (QDir(filename).exists() && !removeRecursively(QString())) { done(SyncFileItem::NormalError, _error); return; @@ -135,7 +135,7 @@ void PropagateLocalRemove::start() } } propagator()->reportProgress(*_item, 0); - propagator()->_journal->deleteFileRecord(_item->_originalFile, _item->_isDirectory); + propagator()->_journal->deleteFileRecord(_item->_originalFile, _item->isDirectory()); propagator()->_journal->commit("Local remove"); done(SyncFileItem::Success); } @@ -245,7 +245,7 @@ void PropagateLocalRename::start() record._checksumHeader = oldRecord._checksumHeader; } - if (!_item->_isDirectory) { // Directories are saved at the end + if (!_item->isDirectory()) { // Directories are saved at the end if (!propagator()->_journal->setFileRecord(record)) { done(SyncFileItem::FatalError, tr("Error writing metadata to the database")); return; diff --git a/src/libsync/propagatorjobs.h b/src/libsync/propagatorjobs.h index 2f7c53df7..04c09cd48 100644 --- a/src/libsync/propagatorjobs.h +++ b/src/libsync/propagatorjobs.h @@ -91,6 +91,6 @@ public: { } void start() Q_DECL_OVERRIDE; - JobParallelism parallelism() Q_DECL_OVERRIDE { return _item->_isDirectory ? WaitForFinished : FullParallelism; } + JobParallelism parallelism() Q_DECL_OVERRIDE { return _item->isDirectory() ? WaitForFinished : FullParallelism; } }; } diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 38353f9eb..f42b5d2d7 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -564,7 +564,6 @@ int SyncEngine::treewalkFile(csync_file_stat_t *file, csync_file_stat_t *other, dir = SyncFileItem::None; // For directories, metadata-only updates will be done after all their files are propagated. if (!isDirectory) { - item->_isDirectory = isDirectory; emit syncItemDiscovered(*item); // Update the database now already: New remote fileid or Etag or RemotePerm @@ -655,7 +654,6 @@ int SyncEngine::treewalkFile(csync_file_stat_t *file, csync_file_stat_t *other, } item->_direction = dir; - item->_isDirectory = isDirectory; if (instruction != CSYNC_INSTRUCTION_NONE) { // check for blacklisting of this item. // if the item is on blacklist, the instruction was set to ERROR @@ -1196,7 +1194,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems) (*it)->_status = SyncFileItem::FileIgnored; (*it)->_errorString = tr("Ignored because of the \"choose what to sync\" blacklist"); - if ((*it)->_isDirectory) { + if ((*it)->isDirectory()) { auto it_base = it; for (SyncFileItemVector::iterator it_next = it + 1; it_next != syncItems.end() && (*it_next)->_file.startsWith(path); ++it_next) { it = it_next; @@ -1221,7 +1219,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems) if (parent_it == syncItems.end() || (*parent_it)->destination() != parentDir) { break; } - ASSERT((*parent_it)->_isDirectory); + ASSERT((*parent_it)->isDirectory()); if ((*parent_it)->_instruction != CSYNC_INSTRUCTION_IGNORE) { break; // already changed } @@ -1249,7 +1247,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems) if (perms.isNull()) { // No permissions set break; - } else if ((*it)->_isDirectory && !perms.contains("K")) { + } else if ((*it)->isDirectory() && !perms.contains("K")) { qCWarning(lcEngine) << "checkForPermission: ERROR" << (*it)->_file; (*it)->_instruction = CSYNC_INSTRUCTION_ERROR; (*it)->_status = SyncFileItem::NormalError; @@ -1271,7 +1269,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems) (*it)->_errorString = tr("Not allowed because you don't have permission to add parent folder"); } - } else if (!(*it)->_isDirectory && !perms.contains("C")) { + } else if (!(*it)->isDirectory() && !perms.contains("C")) { qCWarning(lcEngine) << "checkForPermission: ERROR" << (*it)->_file; (*it)->_instruction = CSYNC_INSTRUCTION_ERROR; (*it)->_status = SyncFileItem::NormalError; @@ -1318,7 +1316,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems) (*it)->_isRestoration = true; (*it)->_errorString = tr("Not allowed to remove, restoring"); - if ((*it)->_isDirectory) { + if ((*it)->isDirectory()) { // restore all sub items for (SyncFileItemVector::iterator it_next = it + 1; it_next != syncItems.end() && (*it_next)->_file.startsWith(path); ++it_next) { @@ -1345,7 +1343,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems) // not delete permission we fast forward the iterator and leave the // delete jobs intact. It is not physically tried to remove this files // underneath, propagator sees that. - if ((*it)->_isDirectory) { + if ((*it)->isDirectory()) { // put a more descriptive message if a top level share dir really is removed. if (it == syncItems.begin() || !(path.startsWith((*(it - 1))->_file))) { (*it)->_errorString = tr("Local files and share folder removed."); @@ -1375,9 +1373,9 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems) if (isRename || destPerms.isNull()) { // no need to check for the destination dir permission destinationOK = true; - } else if ((*it)->_isDirectory && !destPerms.contains("K")) { + } else if ((*it)->isDirectory() && !destPerms.contains("K")) { destinationOK = false; - } else if (!(*it)->_isDirectory && !destPerms.contains("C")) { + } else if (!(*it)->isDirectory() && !destPerms.contains("C")) { destinationOK = false; } @@ -1398,7 +1396,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems) #ifdef OWNCLOUD_RESTORE_RENAME /* We don't like the idea of renaming behind user's back, as the user may be working with the files */ if (!sourceOK && (!destinationOK || isRename) // (not for directory because that's more complicated with the contents that needs to be adjusted) - && !(*it)->_isDirectory) { + && !(*it)->isDirectory()) { // Both the source and the destination won't allow move. Move back to the original std::swap((*it)->_file, (*it)->_renameTarget); (*it)->_direction = SyncFileItem::Down; @@ -1426,7 +1424,7 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems) _anotherSyncNeeded = ImmediateFollowUp; - if ((*it)->_isDirectory) { + if ((*it)->isDirectory()) { for (SyncFileItemVector::iterator it_next = it + 1; it_next != syncItems.end() && (*it_next)->destination().startsWith(path); ++it_next) { it = it_next; diff --git a/src/libsync/syncfileitem.h b/src/libsync/syncfileitem.h index 9ea4e4d45..88ef5ee6d 100644 --- a/src/libsync/syncfileitem.h +++ b/src/libsync/syncfileitem.h @@ -89,7 +89,6 @@ public: SyncFileItem() : _type(UnknownType) , _direction(None) - , _isDirectory(false) , _serverHasIgnoredFiles(false) , _hasBlacklistEntry(false) , _errorMayBeBlacklisted(false) @@ -158,6 +157,11 @@ public: return _file.isEmpty(); } + bool isDirectory() const + { + return _type == SyncFileItem::Directory; + } + /** * True if the item had any kind of error. * @@ -179,7 +183,6 @@ public: QString _renameTarget; Type _type BITFIELD(3); Direction _direction BITFIELD(3); - bool _isDirectory BITFIELD(1); bool _serverHasIgnoredFiles BITFIELD(1); /// Whether there's an entry in the blacklist table. diff --git a/src/libsync/syncresult.cpp b/src/libsync/syncresult.cpp index 88e78320b..52ce018d1 100644 --- a/src/libsync/syncresult.cpp +++ b/src/libsync/syncresult.cpp @@ -132,7 +132,7 @@ void SyncResult::processCompletedItem(const SyncFileItemPtr &item) _foundFilesNotSynced = true; } - if (item->_isDirectory && (item->_instruction == CSYNC_INSTRUCTION_NEW + if (item->isDirectory() && (item->_instruction == CSYNC_INSTRUCTION_NEW || item->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE || item->_instruction == CSYNC_INSTRUCTION_REMOVE || item->_instruction == CSYNC_INSTRUCTION_RENAME)) { diff --git a/test/testsyncengine.cpp b/test/testsyncengine.cpp index 4baa43a13..d96c40695 100644 --- a/test/testsyncengine.cpp +++ b/test/testsyncengine.cpp @@ -309,7 +309,7 @@ private slots: QSet seen; for(const QList &args : completeSpy) { auto item = args[0].value(); - qDebug() << item->_file << item->_isDirectory << item->_status; + 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 == "Y/Z/d2") {