diff --git a/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php b/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php
index d4d08243d2b2d..f9568fadd47dd 100644
--- a/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php
+++ b/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php
@@ -61,7 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
* Watches a asset manager for changes.
*
* This method includes an infinite loop the continuously polls the asset
- * manager for changes.
+ * manager for changes. If available, inotify is used to wait for changes.
*
* @param LazyAssetManager $am The asset manager
* @param string $basePath The base directory to write to
@@ -85,23 +85,45 @@ protected function watch(LazyAssetManager $am, $basePath, OutputInterface $outpu
$previously = array();
}
+ if (function_exists('inotify_init')) {
+ $inotify = inotify_init();
+ } else {
+ $inotify = false;
+ }
+
$error = '';
while (true) {
try {
- foreach ($am->getNames() as $name) {
+ file_put_contents($cache, serialize($previously));
+
+ if (false !== $inotify) {
+ $reload = $this->inotifyWait($am, $basePath, $output, $inotify);
+ } else {
+ sleep(1);
+ $reload = true;
+ }
+
+ $checkAssets = array();
+ if (true === $reload) {
+ // reset the asset manager
+ $prop->setValue($am, array());
+ $am->load();
+
+ $checkAssets = $am->getNames();
+ } else if (is_array($reload)) {
+ $checkAssets = $reload;
+ }
+
+ // need this here to make sure that filemtime is reported correctly
+ clearstatcache();
+
+ foreach ($checkAssets as $name) {
if ($asset = $this->checkAsset($am, $name, $previously)) {
$this->dumpAsset($asset, $basePath, $output);
}
}
- // reset the asset manager
- $prop->setValue($am, array());
- $am->load();
-
- file_put_contents($cache, serialize($previously));
$error = '';
-
- sleep(1);
} catch (\Exception $e) {
if ($error != $msg = $e->getMessage()) {
$output->writeln('
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: