Vfs: Preserve pin state on hydration

For #7322 and #7323
This commit is contained in:
Christian Kamm 2019-07-18 15:30:40 +02:00 committed by Kevin Ottens
parent fc52c5d0cd
commit 5bc2180478
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
2 changed files with 15 additions and 3 deletions

View file

@ -1029,10 +1029,10 @@ void PropagateDownloadFile::downloadFinished()
propagator()->_journal->deleteFileRecord(virtualFile);
// Move the pin state to the new location
auto pin = propagator()->_journal->internalPinStates().rawForPath(_item->_file.toUtf8());
auto pin = propagator()->_journal->internalPinStates().rawForPath(virtualFile.toUtf8());
if (pin && *pin != PinState::Inherited) {
vfs->setPinState(virtualFile, *pin);
vfs->setPinState(_item->_file, PinState::Inherited);
vfs->setPinState(_item->_file, *pin);
vfs->setPinState(virtualFile, PinState::Inherited);
}
}
}

View file

@ -1162,6 +1162,18 @@ private slots:
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(*vfs->pinState("onlinerenamed2/file1rename"), PinState::OnlineOnly);
QCOMPARE(*vfs->pinState("onlinerenamed2/file1rename" DVSUFFIX), PinState::OnlineOnly);
// When a file is hydrated or dehydrated due to pin state it retains its pin state
vfs->setPinState("onlinerenamed2/file1rename" DVSUFFIX, PinState::AlwaysLocal);
QVERIFY(fakeFolder.syncOnce());
QVERIFY(fakeFolder.currentLocalState().find("onlinerenamed2/file1rename"));
QCOMPARE(*vfs->pinState("onlinerenamed2/file1rename"), PinState::AlwaysLocal);
vfs->setPinState("onlinerenamed2", PinState::Unspecified);
vfs->setPinState("onlinerenamed2/file1rename", PinState::OnlineOnly);
QVERIFY(fakeFolder.syncOnce());
QVERIFY(fakeFolder.currentLocalState().find("onlinerenamed2/file1rename" DVSUFFIX));
QCOMPARE(*vfs->pinState("onlinerenamed2/file1rename" DVSUFFIX), PinState::OnlineOnly);
}
};