mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 15:05:19 +03:00
Remove SyncFileItem::_isDirectory
It's always equivalent to _type == SyncFileItem::Directory.
This commit is contained in:
parent
85a93efe51
commit
0f21ed6a5b
13 changed files with 32 additions and 31 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -309,7 +309,7 @@ private slots:
|
|||
QSet<QString> seen;
|
||||
for(const QList<QVariant> &args : completeSpy) {
|
||||
auto item = args[0].value<SyncFileItemPtr>();
|
||||
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") {
|
||||
|
|
Loading…
Reference in a new issue