From aff8008bafb6af1f49b7ed7e9e019383cf43483b Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Thu, 4 May 2017 15:12:14 +0200 Subject: [PATCH] Downloads: Remove empty temporary if disk space full #5746 --- src/libsync/propagatedownload.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index a21deb3d0..823c491d9 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -372,16 +372,23 @@ void PropagateDownloadFile::start() // If there's not enough space to fully download this file, stop. const auto diskSpaceResult = propagator()->diskSpaceCheck(); - if (diskSpaceResult == OwncloudPropagator::DiskSpaceFailure) { - _item->_errorMayBeBlacklisted = true; - done(SyncFileItem::NormalError, - tr("The download would reduce free disk space below %1").arg( - Utility::octetsToString(freeSpaceLimit()))); - return; - } else if (diskSpaceResult == OwncloudPropagator::DiskSpaceCritical) { - done(SyncFileItem::FatalError, - tr("Free space on disk is less than %1").arg( - Utility::octetsToString(criticalFreeSpaceLimit()))); + if (diskSpaceResult != OwncloudPropagator::DiskSpaceOk) { + if (diskSpaceResult == OwncloudPropagator::DiskSpaceFailure) { + _item->_errorMayBeBlacklisted = true; + done(SyncFileItem::NormalError, + tr("The download would reduce free disk space below %1").arg( + Utility::octetsToString(freeSpaceLimit()))); + } else if (diskSpaceResult == OwncloudPropagator::DiskSpaceCritical) { + done(SyncFileItem::FatalError, + tr("Free space on disk is less than %1").arg( + Utility::octetsToString(criticalFreeSpaceLimit()))); + } + + // Remove the temporary, if empty. + if (_resumeStart == 0) { + _tmpFile.remove(); + } + return; } -- 2.30.2