Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
8282cfff
Commit
8282cfff
authored
11 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
Cache the fileinfo in OC\Preview
parent
832f6e4e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/private/preview.php
+126
-115
126 additions, 115 deletions
lib/private/preview.php
with
126 additions
and
115 deletions
lib/private/preview.php
+
126
−
115
View file @
8282cfff
...
...
@@ -52,6 +52,11 @@ class Preview {
static
private
$providers
=
array
();
static
private
$registeredProviders
=
array
();
/**
* @var \OCP\Files\FileInfo
*/
protected
$info
;
/**
* @brief check if thumbnail or bigger version of thumbnail of file is cached
* @param string $user userid - if no user is given, OC_User::getUser will be used
...
...
@@ -160,6 +165,13 @@ class Preview {
return
$this
->
configMaxY
;
}
protected
function
getFileInfo
()
{
if
(
!
$this
->
info
)
{
$this
->
info
=
$this
->
fileView
->
getFileInfo
(
$this
->
file
);
}
return
$this
->
info
;
}
/**
* @brief set the path of the file you want a thumbnail from
* @param string $file
...
...
@@ -167,8 +179,9 @@ class Preview {
*/
public
function
setFile
(
$file
)
{
$this
->
file
=
$file
;
$this
->
info
=
null
;
if
(
$file
!==
''
)
{
$this
->
mimetype
=
$this
->
fileView
->
getMime
T
ype
(
$this
->
file
);
$this
->
mimetype
=
$this
->
getFileInfo
()
->
getMime
t
ype
();
}
return
$this
;
}
...
...
@@ -260,12 +273,11 @@ class Preview {
public
function
deletePreview
()
{
$file
=
$this
->
getFile
();
$fileInfo
=
$this
->
fileView
->
getFileInfo
(
$file
);
$fileId
=
$fileInfo
[
'fileid'
]
;
$fileInfo
=
$this
->
getFileInfo
(
$file
);
$fileId
=
$fileInfo
->
getId
()
;
$previewPath
=
$this
->
getThumbnailsFolder
()
.
'/'
.
$fileId
.
'/'
.
$this
->
getMaxX
()
.
'-'
.
$this
->
getMaxY
()
.
'.png'
;
$this
->
userView
->
unlink
(
$previewPath
);
return
!
$this
->
userView
->
file_exists
(
$previewPath
);
return
$this
->
userView
->
unlink
(
$previewPath
);
}
/**
...
...
@@ -275,13 +287,12 @@ class Preview {
public
function
deleteAllPreviews
()
{
$file
=
$this
->
getFile
();
$fileInfo
=
$this
->
fileView
->
getFileInfo
(
$file
);
$fileId
=
$fileInfo
[
'fileid'
]
;
$fileInfo
=
$this
->
getFileInfo
(
$file
);
$fileId
=
$fileInfo
->
getId
()
;
$previewPath
=
$this
->
getThumbnailsFolder
()
.
'/'
.
$fileId
.
'/'
;
$this
->
userView
->
deleteAll
(
$previewPath
);
$this
->
userView
->
rmdir
(
$previewPath
);
return
!
$this
->
userView
->
is_dir
(
$previewPath
);
return
$this
->
userView
->
rmdir
(
$previewPath
);
}
/**
...
...
@@ -297,8 +308,8 @@ class Preview {
$scalingUp
=
$this
->
getScalingUp
();
$maxScaleFactor
=
$this
->
getMaxScaleFactor
();
$fileInfo
=
$this
->
fileView
->
getFileInfo
(
$file
);
$fileId
=
$fileInfo
[
'fileid'
]
;
$fileInfo
=
$this
->
getFileInfo
(
$file
);
$fileId
=
$fileInfo
->
getId
()
;
if
(
is_null
(
$fileId
))
{
return
false
;
...
...
@@ -386,8 +397,8 @@ class Preview {
$maxY
=
$this
->
getMaxY
();
$scalingUp
=
$this
->
getScalingUp
();
$fileInfo
=
$this
->
fileView
->
getFileInfo
(
$file
);
$fileId
=
$fileInfo
[
'fileid'
]
;
$fileInfo
=
$this
->
getFileInfo
(
$file
);
$fileId
=
$fileInfo
->
getId
()
;
$cached
=
$this
->
isCached
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment