Skip to content

Commit

Permalink
SyncFileStatusTracker: Detect changed in the shared flag
Browse files Browse the repository at this point in the history
... even if the file is not changed.

We get an UPDATE_METADATA in that case, so make sure we let the
SyncFileStatusTracker know about it.
That means we need to filter out UPDATE_METADATA in the other listeners
of this signal.

Issue #6098
  • Loading branch information
ogoffart committed Oct 23, 2017
1 parent ab63984 commit 7ec2f9c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,11 @@ void Folder::slotTransmissionProgress(const ProgressInfo &pi)
// a item is completed: count the errors and forward to the ProgressDispatcher
void Folder::slotItemCompleted(const SyncFileItemPtr &item)
{
if (item->_instruction == CSYNC_INSTRUCTION_NONE || item->_instruction == CSYNC_INSTRUCTION_UPDATE_METADATA) {
// We only care about the updates that deserve to be shown in the UI
return;
}

// add new directories or remove gone away dirs to the watcher
if (item->isDirectory() && item->_instruction == CSYNC_INSTRUCTION_NEW) {
FolderMan::instance()->addMonitorPath(alias(), path() + item->_file);
Expand Down
3 changes: 3 additions & 0 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ int SyncEngine::treewalkFile(csync_file_stat_t *file, csync_file_stat_t *other,
}

_journal->setFileRecordMetadata(item->toSyncJournalFileRecordWithInode(filePath));

// This might have changed the shared flag, so we must notify SyncFileStatusTracker for example
emit itemCompleted(item);
} else {
// The local tree is walked first and doesn't have all the info from the server.
// Update only outdated data from the disk.
Expand Down
2 changes: 1 addition & 1 deletion test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool itemDidComplete(const QSignalSpy &spy, const QString &path)
for(const QList<QVariant> &args : spy) {
auto item = args[0].value<SyncFileItemPtr>();
if (item->destination() == path)
return true;
return item->_instruction != CSYNC_INSTRUCTION_NONE && item->_instruction != CSYNC_INSTRUCTION_UPDATE_METADATA;
}
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions test/testsyncfilestatustracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ private slots:
fakeFolder.remoteModifier().appendByte("S/s1");
fakeFolder.remoteModifier().insert("B/b3");
fakeFolder.remoteModifier().find("B/b3")->extraDavProperties = "<oc:share-types><oc:share-type>0</oc:share-type></oc:share-types>";
fakeFolder.remoteModifier().find("A/a1")->isShared = true; // becomes shared
fakeFolder.remoteModifier().find("A", true); // change the etags of the parent

StatusPushSpy statusSpy(fakeFolder.syncEngine());

Expand All @@ -458,6 +460,7 @@ private slots:
QCOMPARE(statusSpy.statusOf("S/s1"), sharedUpToDateStatus);
QCOMPARE(statusSpy.statusOf("B/b1").shared(), false);
QCOMPARE(statusSpy.statusOf("B/b3"), sharedUpToDateStatus);
QCOMPARE(statusSpy.statusOf("A/a1"), sharedUpToDateStatus);

QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
Expand Down

0 comments on commit 7ec2f9c

Please sign in to comment.