diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index c28ac5849984880dc14631bc30f78357efbbaedf..e4f53a219d29c807f5833954e62cccad68907f7d 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -146,7 +146,9 @@ class File extends Node implements IFile {
 			}
 
 		} catch (\Exception $e) {
-			$partStorage->unlink($internalPartPath);
+			if ($needsPartFile) {
+				$partStorage->unlink($internalPartPath);
+			}
 			$this->convertToSabreException($e);
 		}
 
@@ -176,7 +178,9 @@ class File extends Node implements IFile {
 			try {
 				$this->fileView->changeLock($this->path, ILockingProvider::LOCK_EXCLUSIVE);
 			} catch (LockedException $e) {
-				$partStorage->unlink($internalPartPath);
+				if ($needsPartFile) {
+					$partStorage->unlink($internalPartPath);
+				}
 				throw new FileLocked($e->getMessage(), $e->getCode(), $e);
 			}