INSTRUCTION_IGNORE now carries a direction

This allows IssuesWidget to selectively wipe only the 'Up' ignores
during selective local discovery.
This commit is contained in:
Christian Kamm 2018-02-23 12:13:42 +01:00 committed by Camila San
parent 11b6b48c75
commit a0d5e31423
No known key found for this signature in database
GPG key ID: 7A4A6121E88E2AD4
5 changed files with 33 additions and 12 deletions

View file

@ -148,8 +148,9 @@ void IssuesWidget::hideEvent(QHideEvent *ev)
static bool persistsUntilLocalDiscovery(QTreeWidgetItem *item)
{
const auto status = ProtocolItem::extraData(item).status;
return status == SyncFileItem::Conflict || status == SyncFileItem::FileIgnored;
const auto data = ProtocolItem::extraData(item);
return data.status == SyncFileItem::Conflict
|| (data.status == SyncFileItem::FileIgnored && data.direction == SyncFileItem::Up);
}
void IssuesWidget::cleanItems(const std::function<bool(QTreeWidgetItem *)> &shouldDelete)

View file

@ -106,6 +106,7 @@ ProtocolItem *ProtocolItem::create(const QString &folder, const SyncFileItem &it
data.folderName = folder;
data.status = item._status;
data.size = item._size;
data.direction = item._direction;
ProtocolItem::setExtraData(twitem, data);
return twitem;
}

View file

@ -162,7 +162,8 @@ void SyncRunFileLog::start(const QString &folderPath)
void SyncRunFileLog::logItem(const SyncFileItem &item)
{
// don't log the directory items that are in the list
if (item._direction == SyncFileItem::None) {
if (item._direction == SyncFileItem::None
|| item._instruction == CSYNC_INSTRUCTION_IGNORE) {
return;
}
QString ts = QString::fromLatin1(item._responseTimeStamp);

View file

@ -272,13 +272,29 @@ bool SyncEngine::checkErrorBlacklisting(SyncFileItem &item)
return true;
}
static bool isFileTransferInstruction(csync_instructions_e instruction)
{
return instruction == CSYNC_INSTRUCTION_CONFLICT
|| instruction == CSYNC_INSTRUCTION_NEW
|| instruction == CSYNC_INSTRUCTION_SYNC
|| instruction == CSYNC_INSTRUCTION_TYPE_CHANGE;
}
static bool isFileModifyingInstruction(csync_instructions_e instruction)
{
return isFileTransferInstruction(instruction)
|| instruction == CSYNC_INSTRUCTION_RENAME
|| instruction == CSYNC_INSTRUCTION_REMOVE;
}
void SyncEngine::deleteStaleDownloadInfos(const SyncFileItemVector &syncItems)
{
// Find all downloadinfo paths that we want to preserve.
QSet<QString> download_file_paths;
foreach (const SyncFileItemPtr &it, syncItems) {
if (it->_direction == SyncFileItem::Down
&& it->_type == ItemTypeFile) {
&& it->_type == ItemTypeFile
&& isFileTransferInstruction(it->_instruction)) {
download_file_paths.insert(it->_file);
}
}
@ -299,7 +315,8 @@ void SyncEngine::deleteStaleUploadInfos(const SyncFileItemVector &syncItems)
QSet<QString> upload_file_paths;
foreach (const SyncFileItemPtr &it, syncItems) {
if (it->_direction == SyncFileItem::Up
&& it->_type == ItemTypeFile) {
&& it->_type == ItemTypeFile
&& isFileTransferInstruction(it->_instruction)) {
upload_file_paths.insert(it->_file);
}
}
@ -664,7 +681,6 @@ int SyncEngine::treewalkFile(csync_file_stat_t *file, csync_file_stat_t *other,
dir = !remote ? SyncFileItem::Down : SyncFileItem::Up;
break;
case CSYNC_INSTRUCTION_CONFLICT:
case CSYNC_INSTRUCTION_IGNORE:
case CSYNC_INSTRUCTION_ERROR:
dir = SyncFileItem::None;
break;
@ -692,6 +708,7 @@ int SyncEngine::treewalkFile(csync_file_stat_t *file, csync_file_stat_t *other,
case CSYNC_INSTRUCTION_NEW:
case CSYNC_INSTRUCTION_EVAL:
case CSYNC_INSTRUCTION_STAT_ERROR:
case CSYNC_INSTRUCTION_IGNORE:
default:
dir = remote ? SyncFileItem::Down : SyncFileItem::Up;
break;
@ -1024,7 +1041,9 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
if (!invalidFilenamePattern.isEmpty()) {
const QRegExp invalidFilenameRx(invalidFilenamePattern);
for (auto it = syncItems.begin(); it != syncItems.end(); ++it) {
if ((*it)->_direction == SyncFileItem::Up && (*it)->destination().contains(invalidFilenameRx)) {
if ((*it)->_direction == SyncFileItem::Up
&& isFileModifyingInstruction((*it)->_instruction)
&& (*it)->destination().contains(invalidFilenameRx)) {
(*it)->_errorString = tr("File name contains at least one invalid character");
(*it)->_instruction = CSYNC_INSTRUCTION_IGNORE;
}
@ -1253,7 +1272,8 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
SyncFileItemPtr needle;
for (SyncFileItemVector::iterator it = syncItems.begin(); it != syncItems.end(); ++it) {
if ((*it)->_direction != SyncFileItem::Up) {
if ((*it)->_direction != SyncFileItem::Up
|| !isFileModifyingInstruction((*it)->_instruction)) {
// Currently we only check server-side permissions
continue;
}

View file

@ -185,10 +185,8 @@ void SyncResult::processCompletedItem(const SyncFileItemPtr &item)
// nothing.
break;
}
} else if (item->_direction == SyncFileItem::None) {
if (item->_instruction == CSYNC_INSTRUCTION_IGNORE) {
_foundFilesNotSynced = true;
}
} else if (item->_instruction == CSYNC_INSTRUCTION_IGNORE) {
_foundFilesNotSynced = true;
}
}
}