26
26
namespace OC \Core \Command \Background ;
27
27
28
28
use OC \Core \Command \InterruptedException ;
29
+ use OC \Files \SetupManager ;
30
+ use OCP \BackgroundJob \IJobList ;
29
31
use OCP \ITempManager ;
32
+ use Psr \Log \LoggerInterface ;
30
33
use Symfony \Component \Console \Input \InputArgument ;
31
34
use Symfony \Component \Console \Input \InputInterface ;
32
35
use Symfony \Component \Console \Input \InputOption ;
33
36
use Symfony \Component \Console \Output \OutputInterface ;
34
37
35
38
class JobWorker extends JobBase {
39
+
40
+ public function __construct (
41
+ protected IJobList $ jobList ,
42
+ protected LoggerInterface $ logger ,
43
+ private ITempManager $ tempManager ,
44
+ private SetupManager $ setupManager ,
45
+ ) {
46
+ parent ::__construct ($ jobList , $ logger );
47
+ }
36
48
protected function configure (): void {
37
49
parent ::configure ();
38
50
@@ -103,7 +115,11 @@ static function (string $jobClass) {
103
115
$ job = $ this ->jobList ->getNext (false , $ jobClasses );
104
116
if (!$ job ) {
105
117
if ($ input ->getOption ('once ' ) === true ) {
106
- $ output ->writeln ('No job of classes ' . $ jobClassesString . ' is currently queued ' , OutputInterface::VERBOSITY_VERBOSE );
118
+ if ($ jobClassesString === null ) {
119
+ $ output ->writeln ('No job is currently queued ' , OutputInterface::VERBOSITY_VERBOSE );
120
+ } else {
121
+ $ output ->writeln ('No job of classes ' . $ jobClassesString . ' is currently queued ' , OutputInterface::VERBOSITY_VERBOSE );
122
+ }
107
123
$ output ->writeln ('Exiting... ' , OutputInterface::VERBOSITY_VERBOSE );
108
124
break ;
109
125
}
@@ -120,13 +136,14 @@ static function (string $jobClass) {
120
136
$ this ->printJobInfo ($ job ->getId (), $ job , $ output );
121
137
}
122
138
123
- $ job ->start ($ this ->jobList );
139
+ /** @psalm-suppress DeprecatedMethod Calling execute until it is removed, then will switch to start */
140
+ $ job ->execute ($ this ->jobList );
124
141
125
142
$ output ->writeln ('Job ' . $ job ->getId () . ' has finished ' , OutputInterface::VERBOSITY_VERBOSE );
126
143
127
144
// clean up after unclean jobs
128
- \OC_Util:: tearDownFS ();
129
- \ OC :: $ server -> get (ITempManager::class) ->clean ();
145
+ $ this -> setupManager -> tearDown ();
146
+ $ this -> tempManager ->clean ();
130
147
131
148
$ this ->jobList ->setLastJob ($ job );
132
149
$ this ->jobList ->unlockJob ($ job );
0 commit comments