summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2015-03-09 11:56:46 +0100
committerJoas Schilling <nickvergessen@gmx.de>2015-03-09 11:56:46 +0100
commit01cd83a9020d70458469df29ab2feb891ff5696a (patch)
treeffcaab9c9e5d3811503563d4c90587b74a0da604 /lib
parentfccede8f50f5401587b88a3d9378a70bd30cc1f5 (diff)
parenta12e16e9850fe87d2ee7d4be229b38785eaf5367 (diff)
downloadnextcloud-server-01cd83a9020d70458469df29ab2feb891ff5696a.tar.gz
nextcloud-server-01cd83a9020d70458469df29ab2feb891ff5696a.zip
Merge pull request #14713 from owncloud/issue/14671-preview-delete-check-for-valid-fileid
Check whether the file id is valid, before using it to delete the previews
Diffstat (limited to 'lib')
-rw-r--r--lib/private/preview.php19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/private/preview.php b/lib/private/preview.php
index c7ef00652aa..f45cc0858c7 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);
+ }
}
}
}