Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
a12e16e9
Commit
a12e16e9
authored
Mar 05, 2015
by
Joas Schilling
Browse files
Check whether the file id is valid, before using it to delete the previews
parent
9f5433c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/private/preview.php
View file @
a12e16e9
...
...
@@ -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
[]
=
$
f
ileInfo
;
$toDelete
[]
=
$
this
->
getF
ileInfo
()
;
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
);
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment