Skip to content
Snippets Groups Projects
Commit a12e16e9 authored by Joas Schilling's avatar Joas Schilling
Browse files

Check whether the file id is valid, before using it to delete the previews

parent 9f5433c0
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
namespace OC; namespace OC;
use OC\Preview\Provider; use OC\Preview\Provider;
use OCP\Files\FileInfo;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
class Preview { class Preview {
...@@ -327,21 +328,21 @@ class Preview { ...@@ -327,21 +328,21 @@ class Preview {
* deletes all previews of a file * deletes all previews of a file
*/ */
public function deleteAllPreviews() { public function deleteAllPreviews() {
$file = $this->getFile();
$fileInfo = $this->getFileInfo($file);
$toDelete = $this->getChildren(); $toDelete = $this->getChildren();
$toDelete[] = $fileInfo; $toDelete[] = $this->getFileInfo();
foreach ($toDelete as $delete) { foreach ($toDelete as $delete) {
if ($delete !== null && $delete !== false) { if ($delete instanceof FileInfo) {
/** @var \OCP\Files\FileInfo $delete */ /** @var \OCP\Files\FileInfo $delete */
$fileId = $delete->getId(); $fileId = $delete->getId();
$previewPath = $this->getPreviewPath($fileId); // getId() might return null, e.g. when the file is a
$this->userView->deleteAll($previewPath); // .ocTransferId*.part file from chunked file upload.
$this->userView->rmdir($previewPath); if (!empty($fileId)) {
$previewPath = $this->getPreviewPath($fileId);
$this->userView->deleteAll($previewPath);
$this->userView->rmdir($previewPath);
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment