From: Olivier Goffart Date: Tue, 21 Aug 2018 11:08:09 +0000 (+0200) Subject: New Disco Algo: Handle spurious virtual files X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~518 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5683f1c33d7897fa7756914c9d470cd81ac7ec3f;p=nextcloud-desktop.git New Disco Algo: Handle spurious virtual files Port commit 0b9049e6ff01401883184d29d22dd4a30c092da8 for issue #6718 --- diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 4d877485a..7331cc0bb 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -636,8 +636,32 @@ void ProcessDirectoryJob::processFile(PathTuple path, item->_inode = localEntry.inode; bool typeChange = dbEntry.isValid() && localEntry.isDirectory != (dbEntry._type == ItemTypeDirectory); if (localEntry.isVirtualFile) { - if (item->_type != ItemTypeVirtualFileDownload) + if (!dbEntry.isValid()) { + // Remove the spurious file if it looks like a placeholder file + // (we know placeholder files contain " ") + if (localEntry.size <= 1) { + QString filename = _discoveryData->_localDir + _currentFolder._local + localEntry.name; + QFile::remove(filename); + qCWarning(lcDisco) << "Wiping virtual file without db entry for" << filename; + } else { + qCWarning(lcDisco) << "Virtual file without db entry for" << _currentFolder._local << localEntry.name + << "but looks odd, keeping"; + } + } else if (dbEntry._type == ItemTypeFile) { + // If we find what looks to be a spurious "abc.owncloud" the base file "abc" + // might have been renamed to that. Make sure that the base file is not + // deleted from the server. + if (dbEntry._modtime == localEntry.modtime && dbEntry._fileSize == localEntry.size) { + qCInfo(lcDisco) << "Base file was renamed to virtual file:" << item->_file; + Q_ASSERT(item->_file.endsWith(_discoveryData->_syncOptions._virtualFileSuffix)); + item->_direction = SyncFileItem::Down; + item->_instruction = CSYNC_INSTRUCTION_NEW; + item->_type = ItemTypeVirtualFile; + } + } else if (item->_type != ItemTypeVirtualFileDownload) { item->_type = ItemTypeVirtualFile; + } + if (_queryServer != ParentNotChanged && !serverEntry.isValid()) { item->_instruction = CSYNC_INSTRUCTION_REMOVE; item->_direction = SyncFileItem::Down;