/** * @param \FlameCore\Synchronizer\Files\FilesComparer $diff */ protected function removeObsolete(FilesComparer $diff) { $files = $diff->getObsoleteFiles(); $directories = $diff->getObsoleteDirs(); if ($this->observer) { $this->observer->notify('sync.task.start', ['task' => 'Removing obsolete files', 'total' => count($files)]); } foreach ($files as $file) { if (!$this->target->remove($file)) { $this->fails++; } if ($this->observer) { $this->observer->notify('sync.task.status'); } } foreach ($directories as $directory) { if (!$this->target->removeDir($directory)) { $this->fails++; } } if ($this->observer) { $this->observer->notify('sync.task.finish'); } }
/** * @param string $file * @return bool */ protected function compare($file) { return $this->source->getFileHash($file) !== $this->target->getFileHash($file); }