Vfs suffix: Fix dehydration creating the wrong db entry

This commit is contained in:
Christian Kamm 2019-02-06 15:07:54 +01:00 коммит произвёл Kevin Ottens
Родитель b06f67baf0
Коммит 8a8e93827f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 074BBBCB8DECC9E2
5 изменённых файлов: 27 добавлений и 7 удалений

Просмотреть файл

@ -961,13 +961,20 @@ void ProcessDirectoryJob::processFileFinalize(
QueryMode recurseQueryLocal, QueryMode recurseQueryServer)
{
// Adjust target path for virtual-suffix files
if (item->_type == ItemTypeVirtualFile && isVfsWithSuffix()) {
if (isVfsWithSuffix()) {
if (item->_type == ItemTypeVirtualFile) {
addVirtualFileSuffix(path._target);
if (item->_instruction == CSYNC_INSTRUCTION_RENAME)
addVirtualFileSuffix(item->_renameTarget);
else
addVirtualFileSuffix(item->_file);
}
if (item->_type == ItemTypeVirtualFileDehydration
&& item->_instruction == CSYNC_INSTRUCTION_NEW) {
item->_renameTarget = item->_file;
addVirtualFileSuffix(item->_renameTarget);
}
}
if (path._original != path._target && (item->_instruction == CSYNC_INSTRUCTION_UPDATE_METADATA || item->_instruction == CSYNC_INSTRUCTION_NONE)) {
ASSERT(_dirItem && _dirItem->_instruction == CSYNC_INSTRUCTION_RENAME);

Просмотреть файл

@ -429,7 +429,9 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked()
qCDebug(lcPropagateDownload) << "dehydrating file" << _item->_file;
_item->_type = ItemTypeVirtualFile; // Needed?
vfs->dehydratePlaceholder(*_item);
propagator()->_journal->deleteFileRecord(_item->_file);
propagator()->_journal->deleteFileRecord(_item->_originalFile);
if (!_item->_renameTarget.isEmpty())
_item->_file = _item->_renameTarget;
updateMetadata(false);
return;
}

Просмотреть файл

@ -197,6 +197,8 @@ public:
// Variables useful for everybody
QString _file;
// for renames: the name _file should be renamed to
// for dehydrations: the name _file should become after dehydration (like adding a suffix)
QString _renameTarget;
/// Whether there's end to end encryption on this file.

Просмотреть файл

@ -74,7 +74,7 @@ void VfsSuffix::dehydratePlaceholder(const SyncFileItem &item)
{
QFile::remove(_setupParams.filesystemPath + item._file);
SyncFileItem virtualItem(item);
virtualItem._file.append(fileSuffix());
virtualItem._file = item._renameTarget;
createPlaceholder(virtualItem);
}

Просмотреть файл

@ -668,9 +668,17 @@ private slots:
return !fakeFolder.currentLocalState().find(path)
&& fakeFolder.currentLocalState().find(placeholder);
};
auto hasDehydratedDbEntries = [&](const QString &path) {
SyncJournalFileRecord normal, suffix;
fakeFolder.syncJournal().getFileRecord(path, &normal);
fakeFolder.syncJournal().getFileRecord(path + ".nextcloud", &suffix);
return !normal.isValid() && suffix.isValid() && suffix._type == ItemTypeVirtualFile;
};
QVERIFY(isDehydrated("A/a1"));
QVERIFY(hasDehydratedDbEntries("A/a1"));
QVERIFY(isDehydrated("A/a2"));
QVERIFY(hasDehydratedDbEntries("A/a2"));
QVERIFY(!fakeFolder.currentLocalState().find("B/b1"));
QVERIFY(!fakeFolder.currentRemoteState().find("B/b1"));
@ -679,6 +687,7 @@ private slots:
QVERIFY(!fakeFolder.currentLocalState().find("B/b2"));
QVERIFY(!fakeFolder.currentRemoteState().find("B/b2"));
QVERIFY(isDehydrated("B/b3"));
QVERIFY(hasDehydratedDbEntries("B/b3"));
QVERIFY(itemInstruction(completeSpy, "B/b2", CSYNC_INSTRUCTION_REMOVE));
QVERIFY(itemInstruction(completeSpy, "B/b3.nextcloud", CSYNC_INSTRUCTION_NEW));