mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
UploadDevice: Fix windows issues #7264
- Close the UploadDevice to close the QFile after the PUT job is done. This allows winvfs to get an oplock on the file later. - Don't rely on QFile::fileName() to be valid after openAndSeekFileSharedRead() was called. The way it is openend on Windows makes it have an empty filename.
This commit is contained in:
parent
02a9b16b0f
commit
b99c08904e
@ -91,6 +91,19 @@ void PUTFileJob::start()
|
||||
AbstractNetworkJob::start();
|
||||
}
|
||||
|
||||
bool PUTFileJob::finished()
|
||||
{
|
||||
_device->close();
|
||||
|
||||
qCInfo(lcPutJob) << "PUT of" << reply()->request().url().toString() << "FINISHED WITH STATUS"
|
||||
<< replyStatusString()
|
||||
<< reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute)
|
||||
<< reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute);
|
||||
|
||||
emit finishedSignal();
|
||||
return true;
|
||||
}
|
||||
|
||||
void PollJob::start()
|
||||
{
|
||||
setTimeout(120 * 1000);
|
||||
@ -343,13 +356,17 @@ bool UploadDevice::open(QIODevice::OpenMode mode)
|
||||
if (mode & QIODevice::WriteOnly)
|
||||
return false;
|
||||
|
||||
// Get the file size now: _file.fileName() is no longer reliable
|
||||
// on all platforms after openAndSeekFileSharedRead().
|
||||
auto fileDiskSize = FileSystem::getSize(_file.fileName());
|
||||
|
||||
QString openError;
|
||||
if (!FileSystem::openAndSeekFileSharedRead(&_file, &openError, _start)) {
|
||||
setErrorString(openError);
|
||||
return false;
|
||||
}
|
||||
|
||||
_size = qBound(0ll, _size, FileSystem::getSize(_file.fileName()) - _start);
|
||||
_size = qBound(0ll, _size, fileDiskSize - _start);
|
||||
_read = 0;
|
||||
|
||||
return QIODevice::open(mode);
|
||||
|
||||
@ -121,16 +121,7 @@ public:
|
||||
|
||||
virtual void start() Q_DECL_OVERRIDE;
|
||||
|
||||
virtual bool finished() Q_DECL_OVERRIDE
|
||||
{
|
||||
qCInfo(lcPutJob) << "PUT of" << reply()->request().url().toString() << "FINISHED WITH STATUS"
|
||||
<< replyStatusString()
|
||||
<< reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute)
|
||||
<< reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute);
|
||||
|
||||
emit finishedSignal();
|
||||
return true;
|
||||
}
|
||||
virtual bool finished() Q_DECL_OVERRIDE;
|
||||
|
||||
QIODevice *device()
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user