/** * Sync the in-db project list with a list of file paths * @param array $paths Array of pathnames * @param boolean $remove Should obsolete environments be removed? */ public function syncWithPaths($paths, $dryRun = false) { // Normalise paths in DB foreach ($this as $item) { $real = realpath($item->Filename); if ($real && $real != $item->Filename) { $item->Filename = $real; $item->write(); } } foreach ($paths as $path) { $path = basename($path); if ($this->filter('Filename', $path)->count()) { continue; } $this->message('Adding "' . basename($path) . '" to db'); if (!$dryRun) { $environment = DNEnvironment::create_from_path($path); $environment->ProjectID = $this->projectID; $environment->write(); } } }