| Conditions | 2 |
| Paths | 2 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 56 | public function start(): bool |
||
| 57 | { |
||
| 58 | $lt = (time() - $this->data['max_age']) * 1000; |
||
| 59 | $result = $this->db->selectCollection('fs.files')->find([ |
||
| 60 | 'uploadDate' => ['$lt' => new UTCDateTime($lt)], |
||
| 61 | 'metadata.temporary' => true, |
||
| 62 | ]); |
||
| 63 | |||
| 64 | $count = 0; |
||
| 65 | $gridfs = $this->db->selectGridFSBucket(); |
||
| 66 | |||
| 67 | foreach ($result as $blob) { |
||
| 68 | $gridfs->delete($blob['_id']); |
||
| 69 | ++$count; |
||
| 70 | } |
||
| 71 | |||
| 72 | $this->logger->info('found ['.$count.'] temporary storage blobs for cleanup', [ |
||
| 73 | 'category' => get_class($this), |
||
| 74 | ]); |
||
| 75 | |||
| 76 | return true; |
||
| 77 | } |
||
| 78 | } |
||
| 79 |