diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index c00961b26f372..931f91aede965 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -496,6 +496,7 @@ void ProcessDirectoryJob::processFile(PathTuple path, if (dbEntry._modtime == localEntry.modtime && dbEntry._type == ItemTypeVirtualFile && localEntry.type == ItemTypeFile) { item->_type = ItemTypeFile; + qCInfo(lcDisco) << "Changing item type from virtual to normal file" << item->_file; } // The item shall only have this type if the db request for the virtual download @@ -505,8 +506,10 @@ void ProcessDirectoryJob::processFile(PathTuple path, item->_type = ItemTypeVirtualFile; // Similarly db entries with a dehydration request denote a regular file // until the request is processed. - if (item->_type == ItemTypeVirtualFileDehydration) + if (item->_type == ItemTypeVirtualFileDehydration) { item->_type = ItemTypeFile; + qCInfo(lcDisco) << "Changing item type from virtual to normal file" << item->_file; + } // VFS suffixed files on the server are ignored if (isVfsWithSuffix()) { @@ -1437,8 +1440,10 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( // but it complicates handling a lot and will happen rarely. if (item->_type == ItemTypeVirtualFileDownload) item->_type = ItemTypeVirtualFile; - if (item->_type == ItemTypeVirtualFileDehydration) + if (item->_type == ItemTypeVirtualFileDehydration) { item->_type = ItemTypeFile; + qCInfo(lcDisco) << "Changing item type from virtual to normal file" << item->_file; + } qCInfo(lcDisco) << "Rename detected (up) " << item->_file << " -> " << item->_renameTarget; }; diff --git a/src/libsync/syncfileitem.cpp b/src/libsync/syncfileitem.cpp index 42d8843e99c55..29be0b35f26ff 100644 --- a/src/libsync/syncfileitem.cpp +++ b/src/libsync/syncfileitem.cpp @@ -81,8 +81,10 @@ SyncJournalFileRecord SyncFileItem::toSyncJournalFileRecordWithInode(const QStri // Some types should never be written to the database when propagation completes rec._type = _type; - if (rec._type == ItemTypeVirtualFileDownload) + if (rec._type == ItemTypeVirtualFileDownload) { rec._type = ItemTypeFile; + qCInfo(lcFileItem) << "Changing item type from ItemTypeVirtualFileDownload to normal file to avoid wrong record type in database" << rec._path; + } if (rec._type == ItemTypeVirtualFileDehydration) rec._type = ItemTypeVirtualFile; diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.cpp b/src/libsync/vfs/cfapi/vfs_cfapi.cpp index d622913fd6d1a..595cc52159185 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.cpp +++ b/src/libsync/vfs/cfapi/vfs_cfapi.cpp @@ -396,8 +396,19 @@ void VfsCfApi::requestHydration(const QString &requestId, const QString &path) return; } + bool isNotVirtualFileFailure = false; if (!record.isVirtualFile()) { - qCInfo(lcCfApi) << "Couldn't hydrate, the file is not virtual"; + if (isDehydratedPlaceholder(path)) { + qCWarning(lcCfApi) << "Hydration requested for a placeholder file not marked as virtual in local DB. Attempting to fix it..."; + record._type = ItemTypeVirtualFileDownload; + isNotVirtualFileFailure = !journal->setFileRecord(record); + } else { + isNotVirtualFileFailure = true; + } + } + + if (isNotVirtualFileFailure) { + qCWarning(lcCfApi) << "Couldn't hydrate, the file is not virtual"; emit hydrationRequestFailed(requestId); return; }