Downloads: Remove empty temporary if disk space full #5746
authorChristian Kamm <mail@ckamm.de>
Thu, 4 May 2017 13:12:14 +0000 (15:12 +0200)
committerChristian Kamm <mail@ckamm.de>
Thu, 4 May 2017 13:12:14 +0000 (15:12 +0200)
src/libsync/propagatedownload.cpp

index a21deb3d01cdfbf7510e6af2af5683dde2fcd6af..823c491d9962d88777e21560ed2a0fe4aa77c6a6 100644 (file)
@@ -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;
     }