mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Merge pull request #3993 from nextcloud/bugfix/variousVfsFixes
Bugfix/various vfs fixes
This commit is contained in:
commit
9bebda057a
@ -586,13 +586,18 @@ OCC::CfApiWrapper::FileHandle OCC::CfApiWrapper::handleForPath(const QString &pa
|
||||
return {};
|
||||
}
|
||||
|
||||
if (QFileInfo(path).isDir()) {
|
||||
QFileInfo pathFileInfo(path);
|
||||
if (!pathFileInfo.exists()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (pathFileInfo.isDir()) {
|
||||
HANDLE handle = nullptr;
|
||||
const qint64 openResult = CfOpenFileWithOplock(path.toStdWString().data(), CF_OPEN_FILE_FLAG_NONE, &handle);
|
||||
if (openResult == S_OK) {
|
||||
return {handle, [](HANDLE h) { CfCloseHandle(h); }};
|
||||
}
|
||||
} else {
|
||||
} else if (pathFileInfo.isFile()) {
|
||||
const auto longpath = OCC::FileSystem::longWinPath(path);
|
||||
const auto handle = CreateFile(longpath.toStdWString().data(), 0, 0, nullptr,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
@ -618,7 +623,6 @@ OCC::CfApiWrapper::PlaceHolderInfo OCC::CfApiWrapper::findPlaceholderInfo(const
|
||||
if (result == S_OK) {
|
||||
return info;
|
||||
} else {
|
||||
qCWarning(lcCfApiWrapper()) << "Couldn't get placeholder info" << QString::fromWCharArray(_com_error(result).ErrorMessage());
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@ -709,7 +713,7 @@ OCC::Result<OCC::Vfs::ConvertToPlaceholderResult, QString> OCC::CfApiWrapper::up
|
||||
nullptr, 0, CF_UPDATE_FLAG_MARK_IN_SYNC, nullptr, nullptr);
|
||||
|
||||
if (result != S_OK) {
|
||||
qCWarning(lcCfApiWrapper) << "Couldn't update placeholder info for" << pathForHandle(handle) << ":" << QString::fromWCharArray(_com_error(result).ErrorMessage());
|
||||
qCWarning(lcCfApiWrapper) << "Couldn't update placeholder info for" << pathForHandle(handle) << ":" << QString::fromWCharArray(_com_error(result).ErrorMessage()) << replacesPath;
|
||||
return { "Couldn't update placeholder info" };
|
||||
}
|
||||
|
||||
|
||||
@ -160,6 +160,9 @@ Result<Vfs::ConvertToPlaceholderResult, QString> VfsCfApi::convertToPlaceholder(
|
||||
const auto replacesPath = QDir::toNativeSeparators(replacesFile);
|
||||
|
||||
const auto handle = cfapi::handleForPath(localPath);
|
||||
if (!handle) {
|
||||
return { "Invalid handle for path " + localPath };
|
||||
}
|
||||
if (cfapi::findPlaceholderInfo(handle)) {
|
||||
return cfapi::updatePlaceholderInfo(handle, item._modtime, item._size, item._fileId, replacesPath);
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user