Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
eca57be3
Commit
eca57be3
authored
8 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
Only recurse into incomplete folders during background scans
parent
4ba36688
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/private/Files/Cache/Scanner.php
+6
-3
6 additions, 3 deletions
lib/private/Files/Cache/Scanner.php
lib/public/Files/Cache/IScanner.php
+1
-0
1 addition, 0 deletions
lib/public/Files/Cache/IScanner.php
tests/lib/Files/Cache/ScannerTest.php
+27
-0
27 additions, 0 deletions
tests/lib/Files/Cache/ScannerTest.php
with
34 additions
and
3 deletions
lib/private/Files/Cache/Scanner.php
+
6
−
3
View file @
eca57be3
...
@@ -371,7 +371,7 @@ class Scanner extends BasicEmitter implements IScanner {
...
@@ -371,7 +371,7 @@ class Scanner extends BasicEmitter implements IScanner {
$childQueue
=
$this
->
handleChildren
(
$path
,
$recursive
,
$reuse
,
$folderId
,
$lock
,
$size
);
$childQueue
=
$this
->
handleChildren
(
$path
,
$recursive
,
$reuse
,
$folderId
,
$lock
,
$size
);
foreach
(
$childQueue
as
$child
=>
$childId
)
{
foreach
(
$childQueue
as
$child
=>
$childId
)
{
$childSize
=
$this
->
scanChildren
(
$child
,
self
::
SCAN_RECURSIVE
,
$reuse
,
$childId
,
$lock
);
$childSize
=
$this
->
scanChildren
(
$child
,
$recursive
,
$reuse
,
$childId
,
$lock
);
if
(
$childSize
===
-
1
)
{
if
(
$childSize
===
-
1
)
{
$size
=
-
1
;
$size
=
-
1
;
}
else
if
(
$size
!==
-
1
)
{
}
else
if
(
$size
!==
-
1
)
{
...
@@ -402,6 +402,9 @@ class Scanner extends BasicEmitter implements IScanner {
...
@@ -402,6 +402,9 @@ class Scanner extends BasicEmitter implements IScanner {
if
(
$data
)
{
if
(
$data
)
{
if
(
$data
[
'mimetype'
]
===
'httpd/unix-directory'
and
$recursive
===
self
::
SCAN_RECURSIVE
)
{
if
(
$data
[
'mimetype'
]
===
'httpd/unix-directory'
and
$recursive
===
self
::
SCAN_RECURSIVE
)
{
$childQueue
[
$child
]
=
$data
[
'fileid'
];
$childQueue
[
$child
]
=
$data
[
'fileid'
];
}
else
if
(
$data
[
'mimetype'
]
===
'httpd/unix-directory'
and
$recursive
===
self
::
SCAN_RECURSIVE_INCOMPLETE
and
$data
[
'size'
]
===
-
1
)
{
// only recurse into folders which aren't fully scanned
$childQueue
[
$child
]
=
$data
[
'fileid'
];
}
else
if
(
$data
[
'size'
]
===
-
1
)
{
}
else
if
(
$data
[
'size'
]
===
-
1
)
{
$size
=
-
1
;
$size
=
-
1
;
}
else
if
(
$size
!==
-
1
)
{
}
else
if
(
$size
!==
-
1
)
{
...
@@ -469,8 +472,8 @@ class Scanner extends BasicEmitter implements IScanner {
...
@@ -469,8 +472,8 @@ class Scanner extends BasicEmitter implements IScanner {
}
else
{
}
else
{
$lastPath
=
null
;
$lastPath
=
null
;
while
((
$path
=
$this
->
cache
->
getIncomplete
())
!==
false
&&
$path
!==
$lastPath
)
{
while
((
$path
=
$this
->
cache
->
getIncomplete
())
!==
false
&&
$path
!==
$lastPath
)
{
$this
->
runBackgroundScanJob
(
function
()
use
(
$path
)
{
$this
->
runBackgroundScanJob
(
function
()
use
(
$path
)
{
$this
->
scan
(
$path
,
self
::
SCAN_RECURSIVE
,
self
::
REUSE_ETAG
);
$this
->
scan
(
$path
,
self
::
SCAN_RECURSIVE
_INCOMPLETE
,
self
::
REUSE_ETAG
|
self
::
REUSE_SIZE
);
},
$path
);
},
$path
);
// FIXME: this won't proceed with the next item, needs revamping of getIncomplete()
// FIXME: this won't proceed with the next item, needs revamping of getIncomplete()
// to make this possible
// to make this possible
...
...
This diff is collapsed.
Click to expand it.
lib/public/Files/Cache/IScanner.php
+
1
−
0
View file @
eca57be3
...
@@ -27,6 +27,7 @@ namespace OCP\Files\Cache;
...
@@ -27,6 +27,7 @@ namespace OCP\Files\Cache;
* @since 9.0.0
* @since 9.0.0
*/
*/
interface
IScanner
{
interface
IScanner
{
const
SCAN_RECURSIVE_INCOMPLETE
=
2
;
// only recursive into not fully scanned folders
const
SCAN_RECURSIVE
=
true
;
const
SCAN_RECURSIVE
=
true
;
const
SCAN_SHALLOW
=
false
;
const
SCAN_SHALLOW
=
false
;
...
...
This diff is collapsed.
Click to expand it.
tests/lib/Files/Cache/ScannerTest.php
+
27
−
0
View file @
eca57be3
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
*/
*/
namespace
Test\Files\Cache
;
namespace
Test\Files\Cache
;
use
OC\Files\Cache\CacheEntry
;
use
OC\Files\Cache\CacheEntry
;
/**
/**
...
@@ -150,6 +151,32 @@ class ScannerTest extends \Test\TestCase {
...
@@ -150,6 +151,32 @@ class ScannerTest extends \Test\TestCase {
$this
->
assertFalse
(
$this
->
cache
->
getIncomplete
());
$this
->
assertFalse
(
$this
->
cache
->
getIncomplete
());
}
}
function
testBackgroundScanOnlyRecurseIncomplete
()
{
$this
->
fillTestFolders
();
$this
->
storage
->
mkdir
(
'folder2'
);
$this
->
storage
->
file_put_contents
(
'folder2/bar.txt'
,
'foobar'
);
$this
->
scanner
->
scan
(
''
,
\OC\Files\Cache\Scanner
::
SCAN_SHALLOW
);
$this
->
assertFalse
(
$this
->
cache
->
inCache
(
'folder/bar.txt'
));
$this
->
assertFalse
(
$this
->
cache
->
inCache
(
'folder/2bar.txt'
));
$this
->
assertFalse
(
$this
->
cache
->
inCache
(
'folder2/bar.txt'
));
$this
->
cache
->
put
(
'folder2'
,
[
'size'
=>
1
]);
// mark as complete
$cachedData
=
$this
->
cache
->
get
(
''
);
$this
->
assertEquals
(
-
1
,
$cachedData
[
'size'
]);
$this
->
scanner
->
scan
(
''
,
\OC\Files\Cache\Scanner
::
SCAN_RECURSIVE_INCOMPLETE
,
\OC\Files\Cache\Scanner
::
REUSE_ETAG
|
\OC\Files\Cache\Scanner
::
REUSE_SIZE
);
$this
->
assertTrue
(
$this
->
cache
->
inCache
(
'folder/bar.txt'
));
$this
->
assertTrue
(
$this
->
cache
->
inCache
(
'folder/bar.txt'
));
$this
->
assertFalse
(
$this
->
cache
->
inCache
(
'folder2/bar.txt'
));
$cachedData
=
$this
->
cache
->
get
(
''
);
$this
->
assertNotEquals
(
-
1
,
$cachedData
[
'size'
]);
$this
->
assertFalse
(
$this
->
cache
->
getIncomplete
());
}
public
function
testReuseExisting
()
{
public
function
testReuseExisting
()
{
$this
->
fillTestFolders
();
$this
->
fillTestFolders
();
...
...
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