PluginProbe
Disk Usage Insights / trunk
Disk Usage Insights vtrunk
trunk 1.0 1.10 1.11 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
disk-usage-insights / src / Domain / Collect / DetermineLastModifiedDateJob.php

DetermineLastModifiedDateJob.php in Disk Usage Insights trunk, at src/Domain/Collect/DetermineLastModifiedDateJob.php

41 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Mgleis\DiskUsageInsights\Domain\Collect;
4
5 use Mgleis\DiskUsageInsights\Domain\Jobs\BaseJob;
6
7 class DetermineLastModifiedDateJob extends BaseJob {
8
9 private int $skip;
10 private int $count;
11 private int $totalCount;
12
13 public function __construct(int $skip, int $count, int $totalCount) {
14 $this->skip = $skip;
15 $this->count = $count;
16 $this->totalCount = $totalCount;
17 }
18
19 public function work() {
20 $this->log(self::class);
21 $fileEntries = $this->fileEntryRepository->get($this->skip, $this->count);
22
23 $root = $this->snapshotRepository->load()->root;
24 foreach ($fileEntries as $fileEntry) {
25
26 $absoluteFilename = $this->fileEntryRepository->calcFullPath($fileEntry, $root);
27
28 $fileEntry->last_modified_date = filemtime($absoluteFilename);
29 $this->fileEntryRepository->createOrUpdate($fileEntry);
30 }
31 }
32
33 public function toArray() {
34 return ['type' => self::class, 'args' => [$this->skip, $this->count, $this->totalCount]];
35 }
36
37 public function toDescription(): string {
38 return sprintf('Determining last modified dates... %s%%', round(100 * $this->skip / $this->totalCount));
39 }
40 }
41