ZSync: ensure the temporary file is closed after the download

Otherwise renaming it to the final file will fail on windows
This commit is contained in:
Olivier Goffart 2018-09-20 16:40:36 +02:00
parent 00984b6738
commit 11cf37ac33
2 changed files with 5 additions and 0 deletions

View File

@ -881,6 +881,7 @@ void PropagateDownloadFile::contentChecksumComputed(const QByteArray &checksumTy
void PropagateDownloadFile::downloadFinished()
{
ASSERT(!_tmpFile.isOpen());
QString fn = propagator()->getFilePath(_item->_file);
// In case of file name clash, report an error

View File

@ -129,6 +129,8 @@ bool GETFileZsyncJob::finished()
}
if (!_hasEmittedFinishedSignal) {
_zr.reset();
_zs.reset(); // ensure the file is closed.
emit finishedSignal();
}
@ -179,6 +181,8 @@ void GETFileZsyncJob::seedFinished(void *zs)
if (_nrange == 0 && _item->_size == quint64(zsync_file_length(_zs.get()))) {
_propagator->reportFileTotal(*_item, 0);
_errorStatus = SyncFileItem::Success;
_zr.reset();
_zs.reset(); // ensure the file is closed.
emit finishedSignal();
return;
}