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
a923e755
Unverified
Commit
a923e755
authored
7 years ago
by
Bjoern Schiessle
Browse files
Options
Downloads
Patches
Plain Diff
check if the user still exists before we try to cleanup the previews
Signed-off-by:
Bjoern Schiessle
<
bjoern@schiessle.org
>
parent
a3f86b99
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php
+12
-1
12 additions, 1 deletion
lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php
tests/lib/Repair/NC11/CleanPreviewsBackgroundJobTest.php
+10
-1
10 additions, 1 deletion
tests/lib/Repair/NC11/CleanPreviewsBackgroundJobTest.php
with
22 additions
and
2 deletions
lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php
+
12
−
1
View file @
a923e755
...
...
@@ -30,6 +30,7 @@ use OCP\Files\IRootFolder;
use
OCP\Files\NotFoundException
;
use
OCP\Files\NotPermittedException
;
use
OCP\ILogger
;
use
OCP\IUserManager
;
class
CleanPreviewsBackgroundJob
extends
QueuedJob
{
/** @var IRootFolder */
...
...
@@ -44,6 +45,9 @@ class CleanPreviewsBackgroundJob extends QueuedJob {
/** @var ITimeFactory */
private
$timeFactory
;
/** @var IUserManager */
private
$userManager
;
/**
* CleanPreviewsBackgroundJob constructor.
*
...
...
@@ -51,19 +55,26 @@ class CleanPreviewsBackgroundJob extends QueuedJob {
* @param ILogger $logger
* @param IJobList $jobList
* @param ITimeFactory $timeFactory
* @param IUserManager $userManager
*/
public
function
__construct
(
IRootFolder
$rootFolder
,
ILogger
$logger
,
IJobList
$jobList
,
ITimeFactory
$timeFactory
)
{
ITimeFactory
$timeFactory
,
IUserManager
$userManager
)
{
$this
->
rootFolder
=
$rootFolder
;
$this
->
logger
=
$logger
;
$this
->
jobList
=
$jobList
;
$this
->
timeFactory
=
$timeFactory
;
$this
->
userManager
=
$userManager
;
}
public
function
run
(
$arguments
)
{
$uid
=
$arguments
[
'uid'
];
if
(
!
$this
->
userManager
->
userExists
(
$uid
))
{
$this
->
logger
->
info
(
'User no longer exists, skip user '
.
$uid
);
return
;
}
$this
->
logger
->
info
(
'Started preview cleanup for '
.
$uid
);
$empty
=
$this
->
cleanupPreviews
(
$uid
);
...
...
This diff is collapsed.
Click to expand it.
tests/lib/Repair/NC11/CleanPreviewsBackgroundJobTest.php
+
10
−
1
View file @
a923e755
...
...
@@ -30,6 +30,7 @@ use OCP\Files\IRootFolder;
use
OCP\Files\NotFoundException
;
use
OCP\Files\NotPermittedException
;
use
OCP\ILogger
;
use
OCP\IUserManager
;
use
Test\TestCase
;
class
CleanPreviewsBackgroundJobTest
extends
TestCase
{
...
...
@@ -48,6 +49,9 @@ class CleanPreviewsBackgroundJobTest extends TestCase {
/** @var CleanPreviewsBackgroundJob */
private
$job
;
/** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */
private
$userManager
;
public
function
setUp
()
{
parent
::
setUp
();
...
...
@@ -55,12 +59,17 @@ class CleanPreviewsBackgroundJobTest extends TestCase {
$this
->
logger
=
$this
->
createMock
(
ILogger
::
class
);
$this
->
jobList
=
$this
->
createMock
(
IJobList
::
class
);
$this
->
timeFactory
=
$this
->
createMock
(
ITimeFactory
::
class
);
$this
->
userManager
=
$this
->
createMock
(
IUserManager
::
class
);
$this
->
userManager
->
expects
(
$this
->
any
())
->
method
(
'userExists'
)
->
willReturn
(
true
);
$this
->
job
=
new
CleanPreviewsBackgroundJob
(
$this
->
rootFolder
,
$this
->
logger
,
$this
->
jobList
,
$this
->
timeFactory
);
$this
->
timeFactory
,
$this
->
userManager
);
}
public
function
testCleanupPreviewsUnfinished
()
{
...
...
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