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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
400769ab
Commit
400769ab
authored
13 years ago
by
Bart Visscher
Browse files
Options
Downloads
Patches
Plain Diff
Optimize WebDav access using OC_FileCache
parent
8f6121ff
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/connector/sabre/directory.php
+11
-14
11 additions, 14 deletions
lib/connector/sabre/directory.php
lib/connector/sabre/file.php
+5
-2
5 additions, 2 deletions
lib/connector/sabre/file.php
lib/connector/sabre/node.php
+15
-7
15 additions, 7 deletions
lib/connector/sabre/node.php
with
31 additions
and
23 deletions
lib/connector/sabre/directory.php
+
11
−
14
View file @
400769ab
...
@@ -59,19 +59,22 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
...
@@ -59,19 +59,22 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
* @throws Sabre_DAV_Exception_FileNotFound
* @throws Sabre_DAV_Exception_FileNotFound
* @return Sabre_DAV_INode
* @return Sabre_DAV_INode
*/
*/
public
function
getChild
(
$name
)
{
public
function
getChild
(
$name
,
$info
=
null
)
{
$path
=
$this
->
path
.
'/'
.
$name
;
$path
=
$this
->
path
.
'/'
.
$name
;
if
(
is_null
(
$info
))
{
$info
=
OC_FileCache
::
get
(
$path
);
}
if
(
!
OC_Filesystem
::
file_exists
(
$path
)
)
throw
new
Sabre_DAV_Exception_NotFound
(
'File with name '
.
$path
.
' could not be located'
);
if
(
!
$info
)
throw
new
Sabre_DAV_Exception_NotFound
(
'File with name '
.
$path
.
' could not be located'
);
if
(
OC_Filesystem
::
is_dir
(
$path
)
)
{
if
(
$info
[
'mimetype'
]
==
'httpd/unix-directory'
)
{
return
new
OC_Connector_Sabre_Directory
(
$path
);
return
new
OC_Connector_Sabre_Directory
(
$path
,
$info
);
}
else
{
}
else
{
return
new
OC_Connector_Sabre_File
(
$path
);
return
new
OC_Connector_Sabre_File
(
$path
,
$info
);
}
}
...
@@ -85,17 +88,11 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
...
@@ -85,17 +88,11 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
public
function
getChildren
()
{
public
function
getChildren
()
{
$nodes
=
array
();
$nodes
=
array
();
// foreach(scandir($this->path) as $node) if($node!='.' && $node!='..') $nodes[] = $this->getChild($node);
$folder_content
=
OC_FileCache
::
getFolderContent
(
$this
->
path
);
if
(
OC_Filesystem
::
is_dir
(
$this
->
path
.
'/'
)){
foreach
(
$folder_content
as
$info
)
{
$dh
=
OC_Filesystem
::
opendir
(
$this
->
path
.
'/'
);
$nodes
[]
=
$this
->
getChild
(
$info
[
'name'
],
$info
);
while
((
$node
=
readdir
(
$dh
))
!==
false
){
if
(
$node
!=
'.'
&&
$node
!=
'..'
){
$nodes
[]
=
$this
->
getChild
(
$node
);
}
}
}
}
return
$nodes
;
return
$nodes
;
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
lib/connector/sabre/file.php
+
5
−
2
View file @
400769ab
...
@@ -63,8 +63,8 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
...
@@ -63,8 +63,8 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
* @return int
* @return int
*/
*/
public
function
getSize
()
{
public
function
getSize
()
{
$this
->
stat
();
$this
->
getFileinfoCache
();
return
$this
->
stat
_cache
[
'size'
];
return
$this
->
fileinfo
_cache
[
'size'
];
}
}
...
@@ -92,6 +92,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
...
@@ -92,6 +92,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
* @return mixed
* @return mixed
*/
*/
public
function
getContentType
()
{
public
function
getContentType
()
{
if
(
isset
(
$this
->
fileinfo_cache
[
'mimetype'
]))
{
return
$this
->
fileinfo_cache
[
'mimetype'
];
}
return
OC_Filesystem
::
getMimeType
(
$this
->
path
);
return
OC_Filesystem
::
getMimeType
(
$this
->
path
);
...
...
This diff is collapsed.
Click to expand it.
lib/connector/sabre/node.php
+
15
−
7
View file @
400769ab
...
@@ -33,7 +33,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
...
@@ -33,7 +33,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* file stat cache
* file stat cache
* @var array
* @var array
*/
*/
protected
$
stat
_cache
;
protected
$
fileinfo
_cache
;
/**
/**
* Sets up the node, expects a full path name
* Sets up the node, expects a full path name
...
@@ -41,8 +41,11 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
...
@@ -41,8 +41,11 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* @param string $path
* @param string $path
* @return void
* @return void
*/
*/
public
function
__construct
(
$path
)
{
public
function
__construct
(
$path
,
$fileinfo_cache
=
null
)
{
$this
->
path
=
$path
;
$this
->
path
=
$path
;
if
(
$fileinfo_cache
)
{
$this
->
fileinfo_cache
=
$fileinfo_cache
;
}
}
}
...
@@ -85,9 +88,14 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
...
@@ -85,9 +88,14 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
/**
/**
* Set the stat cache
* Set the stat cache
*/
*/
protected
function
stat
()
{
protected
function
getFileinfoCache
()
{
if
(
!
isset
(
$this
->
stat_cache
))
{
if
(
!
isset
(
$this
->
fileinfo_cache
))
{
$this
->
stat_cache
=
OC_Filesystem
::
stat
(
$this
->
path
);
if
(
$fileinfo_cache
=
OC_FileCache
::
get
(
$this
->
path
))
{
}
else
{
$fileinfo_cache
=
OC_Filesystem
::
stat
(
$this
->
path
);
}
$this
->
fileinfo_cache
=
$fileinfo_cache
;
}
}
}
}
...
@@ -97,8 +105,8 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
...
@@ -97,8 +105,8 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* @return int
* @return int
*/
*/
public
function
getLastModified
()
{
public
function
getLastModified
()
{
$this
->
stat
();
$this
->
getFileinfoCache
();
return
$this
->
stat
_cache
[
'mtime'
];
return
$this
->
fileinfo
_cache
[
'mtime'
];
}
}
...
...
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