Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
PublishStashedFileJob | |
0.00% |
0 / 19 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getDeduplicationInfo | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
logJobParams | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
getUpload | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
19 | * @defgroup JobQueue JobQueue |
20 | */ |
21 | |
22 | /** |
23 | * Upload a file from the upload stash into the local file repo. |
24 | * |
25 | * @ingroup Upload |
26 | * @ingroup JobQueue |
27 | */ |
28 | class PublishStashedFileJob extends Job implements GenericParameterJob { |
29 | use UploadJobTrait; |
30 | |
31 | public function __construct( array $params ) { |
32 | parent::__construct( 'PublishStashedFile', $params ); |
33 | $this->removeDuplicates = true; |
34 | $this->initialiseUploadJob( $this->params['filekey'] ); |
35 | } |
36 | |
37 | public function getDeduplicationInfo() { |
38 | $info = parent::getDeduplicationInfo(); |
39 | if ( is_array( $info['params'] ) ) { |
40 | $info['params'] = [ 'filekey' => $info['params']['filekey'] ]; |
41 | } |
42 | |
43 | return $info; |
44 | } |
45 | |
46 | /** |
47 | * Get the parameters for job logging |
48 | * |
49 | * @param Status[] $status |
50 | * @return array |
51 | */ |
52 | public function logJobParams( $status ): array { |
53 | return [ |
54 | 'stage' => $status['stage'] ?? '-', |
55 | 'result' => $status['result'] ?? '-', |
56 | 'status' => (string)( $status['status'] ?? '-' ), |
57 | 'filekey' => $this->params['filekey'], |
58 | 'filename' => $this->params['filename'], |
59 | 'user' => $this->user->getName(), |
60 | ]; |
61 | } |
62 | |
63 | /** |
64 | * getter for the upload |
65 | * |
66 | * @return UploadFromStash |
67 | */ |
68 | protected function getUpload(): UploadBase { |
69 | if ( $this->upload === null ) { |
70 | $this->upload = new UploadFromStash( $this->user ); |
71 | // @todo initialize() causes a GET, ideally we could frontload the antivirus |
72 | // checks and anything else to the stash stage (which includes concatenation and |
73 | // the local file is thus already there). That way, instead of GET+PUT, there could |
74 | // just be a COPY operation from the stash to the public zone. |
75 | $this->upload->initialize( $this->params['filekey'], $this->params['filename'] ); |
76 | } |
77 | return $this->upload; |
78 | } |
79 | } |