Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.10] Enforce virtual file type when it is falsely marked as non-virtual. Added more logs for scenarios when virtual placeholder gets marked as non-virtual. #6172

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()) {
Expand Down Expand Up @@ -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;
};
Expand Down
4 changes: 3 additions & 1 deletion src/libsync/syncfileitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 12 additions & 1 deletion src/libsync/vfs/cfapi/vfs_cfapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading