10000 [FrameworkBundle] Fix cache:clear on vagrant by nicolas-grekas · Pull Request #27231 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Fix cache:clear on vagrant #27231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle] Fix cache:clear on vagrant
  • Loading branch information
nicolas-grekas committed May 11, 2018
commit 3381611d86e684737c064efef0d937e08a801a63
30 changes: 24 additions & 6 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,34 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

$containerDir = $fs->exists($warmupDir.'/'.$containerDir) ? false : $containerDir;
if (!$fs->exists($warmupDir.'/'.$containerDir)) {
$fs->rename($realCacheDir.'/'.$containerDir, $warmupDir.'/'.$containerDir);
touch($warmupDir.'/'.$containerDir.'.legacy');
}

$fs->rename($realCacheDir, $oldCacheDir);
$fs->rename($warmupDir, $realCacheDir);
if ('/' === \DIRECTORY_SEPARATOR && $mounts = @file('/proc/mounts')) {
foreach ($mounts as $mount) {
$mount = array_slice(explode(' ', $mount), 1, -3);
if (!\in_array(array_pop($mount), array('vboxfs', 'nfs'))) {
continue;
}
$mount = implode(' ', $mount).'/';

if ($containerDir) {
$fs->rename($oldCacheDir.'/'.$containerDir, $realCacheDir.'/'.$containerDir);
touch($realCacheDir.'/'.$containerDir.'.legacy');
if (0 === strpos($realCacheDir, $mount)) {
$io->note('For better performances, you should move the cache and log directories to a non-shared folder of the VM.');
$oldCacheDir = false;
break;
}
}
}

if ($oldCacheDir) {
$fs->rename($realCacheDir, $oldCacheDir);
} else {
$fs->remove($realCacheDir);
}
$fs->rename($warmupDir, $realCacheDir);

if ($output->isVerbose()) {
$io->comment('Removing old cache directory...');
}
Expand Down
0