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
251b676a
Commit
251b676a
authored
12 years ago
by
Thomas Müller
Browse files
Options
Downloads
Plain Diff
Merge pull request #1616 from owncloud/cache_fixes_rebase
Cache: reuse known folder sizes when doing a shallow scan - rebase
parents
8d9352a4
b54dcd19
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/files/cache/scanner.php
+19
-12
19 additions, 12 deletions
lib/files/cache/scanner.php
tests/lib/files/cache/watcher.php
+0
-1
0 additions, 1 deletion
tests/lib/files/cache/watcher.php
with
19 additions
and
13 deletions
lib/files/cache/scanner.php
+
19
−
12
View file @
251b676a
...
...
@@ -58,9 +58,10 @@ class Scanner {
* scan a single file and store it in the cache
*
* @param string $file
* @param bool $checkExisting check existing folder sizes in the cache instead of always using -1 for folder size
* @return array with metadata of the scanned file
*/
public
function
scanFile
(
$file
)
{
public
function
scanFile
(
$file
,
$checkExisting
=
false
)
{
\OC_Hook
::
emit
(
'\OC\Files\Cache\Scanner'
,
'scan_file'
,
array
(
'path'
=>
$file
,
'storage'
=>
$this
->
storageId
));
$data
=
$this
->
getData
(
$file
);
if
(
$data
)
{
...
...
@@ -73,7 +74,15 @@ class Scanner {
$this
->
scanFile
(
$parent
);
}
}
$id
=
$this
->
cache
->
put
(
$file
,
$data
);
if
(
$checkExisting
and
$cacheData
=
$this
->
cache
->
get
(
$file
))
{
if
(
$data
[
'size'
]
===
-
1
)
{
$data
[
'size'
]
=
$cacheData
[
'size'
];
}
if
(
$data
[
'mtime'
]
===
$cacheData
[
'mtime'
])
{
$data
[
'etag'
]
=
$cacheData
[
'etag'
];
}
}
$this
->
cache
->
put
(
$file
,
$data
);
}
return
$data
;
}
...
...
@@ -99,20 +108,18 @@ class Scanner {
while
(
$file
=
readdir
(
$dh
))
{
if
(
!
$this
->
isIgnoredFile
(
$file
))
{
$child
=
(
$path
)
?
$path
.
'/'
.
$file
:
$file
;
$data
=
$this
->
scanFile
(
$child
);
$data
=
$this
->
scanFile
(
$child
,
$recursive
===
self
::
SCAN_SHALLOW
);
if
(
$data
)
{
if
(
$data
[
'
mimetyp
e'
]
===
'httpd/unix-directory'
)
{
if
(
$data
[
'
siz
e'
]
===
-
1
)
{
if
(
$recursive
===
self
::
SCAN_RECURSIVE
)
{
$childQueue
[]
=
$child
;
$data
[
'size'
]
=
0
;
}
else
{
$
data
[
'
size
'
]
=
-
1
;
$size
=
-
1
;
}
}
else
{
}
if
(
$data
[
'size'
]
===
-
1
)
{
$size
=
-
1
;
}
elseif
(
$size
!==
-
1
)
{
if
(
$size
!==
-
1
)
{
$size
+=
$data
[
'size'
];
}
}
...
...
@@ -143,8 +150,8 @@ class Scanner {
*/
private
function
isIgnoredFile
(
$file
)
{
if
(
$file
===
'.'
||
$file
===
'..'
||
pathinfo
(
$file
,
PATHINFO_EXTENSION
)
===
'part'
)
{
||
pathinfo
(
$file
,
PATHINFO_EXTENSION
)
===
'part'
)
{
return
true
;
}
return
false
;
...
...
This diff is collapsed.
Click to expand it.
tests/lib/files/cache/watcher.php
+
0
−
1
View file @
251b676a
...
...
@@ -76,7 +76,6 @@ class Watcher extends \PHPUnit_Framework_TestCase {
$updater
->
checkUpdate
(
''
);
$entry
=
$cache
->
get
(
'foo.txt'
);
$this
->
assertEquals
(
-
1
,
$entry
[
'size'
]);
$this
->
assertEquals
(
'httpd/unix-directory'
,
$entry
[
'mimetype'
]);
$this
->
assertFalse
(
$cache
->
inCache
(
'folder'
));
$this
->
assertFalse
(
$cache
->
inCache
(
'folder/bar.txt'
));
...
...
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