Check whether the file id is valid, before using it to delete the previews
This commit is contained in:
parent
9f5433c0c3
commit
a12e16e985
1 changed files with 10 additions and 9 deletions
|
@ -14,6 +14,7 @@
|
|||
namespace OC;
|
||||
|
||||
use OC\Preview\Provider;
|
||||
use OCP\Files\FileInfo;
|
||||
use OCP\Files\NotFoundException;
|
||||
|
||||
class Preview {
|
||||
|
@ -327,24 +328,24 @@ 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();
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check if thumbnail or bigger version of thumbnail of file is cached
|
||||
|
|
Loading…
Reference in a new issue