/**
  * @param \FlameCore\Synchronizer\Files\FilesComparer $diff
  */
 protected function addMissing(FilesComparer $diff)
 {
     $files = $diff->getMissingFiles();
     $directories = $diff->getMissingDirs();
     if ($this->observer) {
         $this->observer->notify('sync.task.start', ['task' => 'Adding missing files', 'total' => count($files)]);
     }
     foreach ($directories as $directory) {
         if (!$this->target->createDir($directory)) {
             $this->fails++;
         }
     }
     foreach ($files as $file) {
         $content = $this->source->get($file);
         if ($content === false || !$this->target->put($file, $content, 0777)) {
             $this->fails++;
         }
         if ($this->observer) {
             $this->observer->notify('sync.task.status');
         }
     }
     if ($this->observer) {
         $this->observer->notify('sync.task.finish');
     }
 }