Conditions | 3 |
Paths | 3 |
Total Lines | 35 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
40 | public function start(): bool |
||
41 | { |
||
42 | $cursor = $this->db->storage->aggregate([ |
||
43 | ['$unwind' => '$history'], |
||
44 | ['$match' => [ |
||
45 | 'history.hash' => ['$exists' => 0], |
||
46 | ]], |
||
47 | ['$lookup' => [ |
||
48 | 'from' => 'fs.files', |
||
49 | 'foreignField' => '_id', |
||
50 | 'localField' => 'history.storage._id', |
||
51 | 'as' => 'blob', |
||
52 | ]], |
||
53 | ]); |
||
54 | |||
55 | foreach ($cursor as $object) { |
||
56 | if (count($object['blob']) === 0) { |
||
57 | continue; |
||
58 | } |
||
59 | |||
60 | $this->db->storage->updateOne( |
||
61 | [ |
||
62 | '_id' => $object['_id'], |
||
63 | 'history.version' => $object['history']['version'], |
||
64 | ], |
||
65 | [ |
||
66 | '$set' => [ |
||
67 | 'history.$.hash' => $object['blob']['md5'], |
||
68 | ], |
||
69 | ] |
||
70 | ); |
||
71 | } |
||
72 | |||
73 | return true; |
||
74 | } |
||
75 | } |
||
76 |