skip = $skip; $this->count = $count; $this->totalCount = $totalCount; } public function work() { $dirEntries = $this->fileEntryRepository->get($this->skip, $this->count, FileEntry::TYPE_DIR); $root = $this->snapshotRepository->load()->root; foreach ($dirEntries as $dirEntry) { $realDir = $this->fileEntryRepository->calcFullPath($dirEntry, $root); //$this->log("Scanning " . $realDir . " for files..."); $files = scandir($realDir . '/'); foreach ($files as $file) { if (!is_file($realDir . '/' . $file)) { continue; } // persist file info $fileEntry = new FileEntry(); $fileEntry->parent_id = $dirEntry->id; $fileEntry->name = $file; $fileEntry->type = FileEntry::TYPE_FILE; $fileEntry->size = 0; $this->fileEntryRepository->createOrUpdate($fileEntry); } } } public function toArray() { return ['type' => self::class, 'args' => [$this->skip, $this->count, $this->totalCount]]; } public function toDescription(): string { $percent = $this->totalCount > 0 ? round(100 * $this->skip / $this->totalCount) : '0'; return sprintf('Scanning dirs for files... %s%%', $percent); } }