diff options
author | allexzander <blackslayer4@gmail.com> | 2021-07-13 15:19:04 +0300 |
---|---|---|
committer | allexzander (Rebase PR Action) <allexzander@users.noreply.github.com> | 2021-08-20 15:57:22 +0300 |
commit | c28cac8479858215b68a4056e5e5b9e123c04631 (patch) | |
tree | 617ba8efb17c8072bb59bff81990f6f9756e8907 /src/libsync/discovery.cpp | |
parent | 2c78925acbce7fef64867696551cdee9bda62636 (diff) |
VFS + E2EE placeholder size migration from old versions.
Signed-off-by: allexzander <blackslayer4@gmail.com>
Diffstat (limited to 'src/libsync/discovery.cpp')
-rw-r--r-- | src/libsync/discovery.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index a20697336..8252c82fc 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -462,11 +462,14 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo( if (dbEntry.isValid()) { qint64 size = serverEntry.size; + bool metaDataSizeNeedsUpdateForE2EEFile = false; + if (dbEntry.isVirtualFile() && (!item->_encryptedFileName.isEmpty()) && size > 0) { // make sure we set correct size when file was downloaded previously and has now been changed on the server // serverEntry always includes extra CommonConstants::e2EeTagSize bytes for e2e encrypted files // we don't need those neither when creating a placeholder nor when storing hydrated file on disk size = serverEntry.size - CommonConstants::e2EeTagSize; + metaDataSizeNeedsUpdateForE2EEFile = dbEntry._fileSize == serverEntry.size; } if (serverEntry.isDirectory != dbEntry.isDirectory()) { @@ -496,14 +499,32 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo( } else { item->_instruction = CSYNC_INSTRUCTION_SYNC; } - } else if (dbEntry._remotePerm != serverEntry.remotePerm || dbEntry._fileId != serverEntry.fileId) { + } else if (dbEntry._remotePerm != serverEntry.remotePerm || dbEntry._fileId != serverEntry.fileId || metaDataSizeNeedsUpdateForE2EEFile) { + if (metaDataSizeNeedsUpdateForE2EEFile) { + item->_size = serverEntry.size - CommonConstants::e2EeTagSize; + } item->_instruction = CSYNC_INSTRUCTION_UPDATE_METADATA; item->_direction = SyncFileItem::Down; } else { // if (is virtual mode enabled and folder is encrypted - check if the size is the same as on the server and then - trigger server query // to update a placeholder with corrected size (-16 Bytes) // or, maybe, add a flag to the database - vfsE2eeSizeCorrected? if it is not set - subtract it from the placeholder's size and re-create/update a placeholder? - processFileAnalyzeLocalInfo(item, path, localEntry, serverEntry, dbEntry, ParentNotChanged); + QueryMode serverQueryMode = ParentNotChanged; + if (dbEntry.isDirectory() && dbEntry._isE2eEncrypted) { + qint64 totalSizeOfPath = 0; + if (_discoveryData->_statedb->listFilesInPath(dbEntry.path().toUtf8(), [this, &totalSizeOfPath](const OCC::SyncJournalFileRecord &record) { + if (record.isFile()) { + totalSizeOfPath += record._fileSize + CommonConstants::e2EeTagSize; + } else if (record.isVirtualFile()) { + totalSizeOfPath += record._fileSize; + } + })) { + if (totalSizeOfPath != 0 && totalSizeOfPath == serverEntry.sizeOfFolder) { + serverQueryMode = NormalQuery; + } + } + } + processFileAnalyzeLocalInfo(item, path, localEntry, serverEntry, dbEntry, serverQueryMode); return; } |