mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 06:45:49 +03:00
PropagateDownload: Don't try to open readonly temporaries
This situation could arrise when receiving a read-only share and the temporary rename failed for some reason. See #7419
This commit is contained in:
parent
f78c4f851b
commit
3446412d92
1 changed files with 15 additions and 13 deletions
|
@ -523,24 +523,26 @@ void PropagateDownloadFile::startDownload()
|
|||
if (tmpFileName.isEmpty()) {
|
||||
tmpFileName = createDownloadTmpFileName(_item->_file);
|
||||
}
|
||||
|
||||
_tmpFile.setFileName(propagator()->getFilePath(tmpFileName));
|
||||
if (!_tmpFile.open(QIODevice::Append | QIODevice::Unbuffered)) {
|
||||
done(SyncFileItem::NormalError, _tmpFile.errorString());
|
||||
|
||||
_resumeStart = _tmpFile.size();
|
||||
if (_resumeStart > 0 && _resumeStart == _item->_size) {
|
||||
qCInfo(lcPropagateDownload) << "File is already complete, no need to download";
|
||||
downloadFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
FileSystem::setFileHidden(_tmpFile.fileName(), true);
|
||||
|
||||
_resumeStart = _tmpFile.size();
|
||||
if (_resumeStart > 0) {
|
||||
if (_resumeStart == _item->_size) {
|
||||
qCInfo(lcPropagateDownload) << "File is already complete, no need to download";
|
||||
_tmpFile.close();
|
||||
downloadFinished();
|
||||
return;
|
||||
}
|
||||
// Can't open(Append) read-only files, make sure to make
|
||||
// file writable if it exists.
|
||||
if (_tmpFile.exists())
|
||||
FileSystem::setFileReadOnly(_tmpFile.fileName(), false);
|
||||
if (!_tmpFile.open(QIODevice::Append | QIODevice::Unbuffered)) {
|
||||
qCWarning(lcPropagateDownload) << "could not open temporary file" << _tmpFile.fileName();
|
||||
done(SyncFileItem::NormalError, _tmpFile.errorString());
|
||||
return;
|
||||
}
|
||||
// Hide temporary after creation
|
||||
FileSystem::setFileHidden(_tmpFile.fileName(), true);
|
||||
|
||||
// If there's not enough space to fully download this file, stop.
|
||||
const auto diskSpaceResult = propagator()->diskSpaceCheck();
|
||||
|
|
Loading…
Reference in a new issue