Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d6ab01e

Browse files
[FrameworkBundle] Fix cache:clear on vagrant
1 parent 40bcd77 commit d6ab01e

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,34 @@ protected function execute(InputInterface $input, OutputInterface $output)
140140
}
141141
}
142142

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

145-
$fs->rename($realCacheDir, $oldCacheDir);
146-
$fs->rename($warmupDir, $realCacheDir);
148+
if ('/' === \DIRECTORY_SEPARATOR && $mounts = @file('/proc/mounts')) {
149+
foreach ($mounts as $mount) {
150+
$mount = array_slice(explode(' ', $mount), 1, -3);
151+
if (!\in_array(array_pop($mount), array('vboxfs', 'nfs'))) {
152+
continue;
153+
}
154+
$mount = implode(' ', $mount).'/';
147155

148-
if ($containerDir) {
149-
$fs->rename($oldCacheDir.'/'.$containerDir, $realCacheDir.'/'.$containerDir);
150-
touch($realCacheDir.'/'.$containerDir.'.legacy');
156+
if (0 === strpos($realCacheDir, $mount)) {
157+
$io->note("For better performances, you should move the cache/ and log/ directories to a non-shared folder of your vm.");
158+
$oldCacheDir = false;
159+
break;
160+
}
161+
}
151162
}
152163

164+
if ($oldCacheDir) {
165+
$fs->rename($realCacheDir, $oldCacheDir);
166+
} else {
167+
$fs->remove($realCacheDir);
168+
}
169+
$fs->rename($warmupDir, $realCacheDir);
170+
153171
if ($output->isVerbose()) {
154172
$io->comment('Removing old cache directory...');
155173
}

0 commit comments

Comments
 (0)