From 11cf37ac335d381bf7e343bb64ae5b0ce0d2e47c Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 20 Sep 2018 16:40:36 +0200 Subject: [PATCH] ZSync: ensure the temporary file is closed after the download Otherwise renaming it to the final file will fail on windows --- src/libsync/propagatedownload.cpp | 1 + src/libsync/propagatedownloadzsync.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index b8aa15e0f8..6356e24da3 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -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 diff --git a/src/libsync/propagatedownloadzsync.cpp b/src/libsync/propagatedownloadzsync.cpp index 1bece1bae4..ae80b53c5c 100644 --- a/src/libsync/propagatedownloadzsync.cpp +++ b/src/libsync/propagatedownloadzsync.cpp @@ -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; }