Skip to content

Commit

Permalink
[FrameworkBundle] avoids cache:clear to break if new/old folders alre…
Browse files Browse the repository at this point in the history
…ady exist
  • Loading branch information
jfsimon authored and fabpot committed Mar 6, 2013
1 parent 0e7b5fb commit 1d3da29
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
Expand Up @@ -62,23 +62,32 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
}

$filesystem = $this->getContainer()->get('filesystem');
$kernel = $this->getContainer()->get('kernel');
$output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));

$this->getContainer()->get('cache_clearer')->clear($realCacheDir);

if ($filesystem->exists($oldCacheDir)) {
$filesystem->remove($oldCacheDir);
}

if ($input->getOption('no-warmup')) {
rename($realCacheDir, $oldCacheDir);
$filesystem->rename($realCacheDir, $oldCacheDir);
} else {
$warmupDir = $realCacheDir.'_new';

if ($filesystem->exists($warmupDir)) {
$filesystem->remove($warmupDir);
}

$this->warmup($warmupDir, !$input->getOption('no-optional-warmers'));

rename($realCacheDir, $oldCacheDir);
rename($warmupDir, $realCacheDir);
$filesystem->rename($realCacheDir, $oldCacheDir);
$filesystem->rename($warmupDir, $realCacheDir);
}

$this->getContainer()->get('filesystem')->remove($oldCacheDir);
$filesystem->remove($oldCacheDir);
}

protected function warmup($warmupDir, $enableOptionalWarmers = true)
Expand Down

0 comments on commit 1d3da29

Please sign in to comment.