PluginProbe
Disk Usage Insights / 1.4
Disk Usage Insights v1.4
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 1.4, at src/Domain/Collect/DetermineLastModifiedDateJob.php

44 lines 1.4 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\FileEntry;
6 use Mgleis\DiskUsageInsights\Domain\Jobs\BaseJob;
7 use Mgleis\DiskUsageInsights\Domain\Jobs\PhaseCoordinatorJob;
8
9 class DetermineLastModifiedDateJob extends BaseJob {
10
11 private int $skip;
12 private int $count;
13 private int $totalCount;
14
15 public function __construct(int $skip, int $count, int $totalCount) {
16 $this->skip = $skip;
17 $this->count = $count;
18 $this->totalCount = $totalCount;
19 }
20
21 public function work() {
22 $this->log(self::class);
23 $fileEntries = $this->fileEntryRepository->get($this->skip, $this->count);
24
25 $root = $this->snapshotRepository->load()->root;
26 foreach ($fileEntries as $fileEntry) {
27
28 $absoluteFilename = $this->fileEntryRepository->calcFullPath($fileEntry, $root);
29 $this->log($absoluteFilename);
30
31 $fileEntry->last_modified_date = filemtime($absoluteFilename);
32 $this->fileEntryRepository->createOrUpdate($fileEntry);
33 }
34 }
35
36 public function toArray() {
37 return ['type' => self::class, 'args' => [$this->skip, $this->count, $this->totalCount]];
38 }
39
40 public function toDescription(): string {
41 return sprintf('Determining last modified dates... %s%%', round(100 * $this->skip / $this->totalCount));
42 }
43 }
44