[Pkg-owncloud-commits] [owncloud] 17/118: Check whether the file id is valid, before using it to delete the previews

David Prévot taffit at moszumanska.debian.org
Fri Mar 27 22:13:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit c100d90793235b00ed8a0a34fd3607d36a254715
Author: Joas Schilling <nickvergessen at owncloud.com>
Date:   Thu Mar 5 16:07:42 2015 +0100

    Check whether the file id is valid, before using it to delete the previews
---
 lib/private/preview.php | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/private/preview.php b/lib/private/preview.php
index c7ef006..f45cc08 100644
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -14,6 +14,7 @@
 namespace OC;
 
 use OC\Preview\Provider;
+use OCP\Files\FileInfo;
 use OCP\Files\NotFoundException;
 
 class Preview {
@@ -327,21 +328,21 @@ class Preview {
 	 * deletes all previews of a file
 	 */
 	public function deleteAllPreviews() {
-		$file = $this->getFile();
-
-		$fileInfo = $this->getFileInfo($file);
-
 		$toDelete = $this->getChildren();
-		$toDelete[] = $fileInfo;
+		$toDelete[] = $this->getFileInfo();
 
 		foreach ($toDelete as $delete) {
-			if ($delete !== null && $delete !== false) {
+			if ($delete instanceof FileInfo) {
 				/** @var \OCP\Files\FileInfo $delete */
 				$fileId = $delete->getId();
 
-				$previewPath = $this->getPreviewPath($fileId);
-				$this->userView->deleteAll($previewPath);
-				$this->userView->rmdir($previewPath);
+				// getId() might return null, e.g. when the file is a
+				// .ocTransferId*.part file from chunked file upload.
+				if (!empty($fileId)) {
+					$previewPath = $this->getPreviewPath($fileId);
+					$this->userView->deleteAll($previewPath);
+					$this->userView->rmdir($previewPath);
+				}
 			}
 		}
 	}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list