Пример #1
0
 public function deleteMatched($matcher, array $options = [])
 {
     $allFiles = Toolbox\FileTools::searchFile($this->basePath);
     foreach ($allFiles as $file) {
         $key = urldecode(substr($file, strrpos($file, DIRECTORY_SEPARATOR) + 1));
         if (preg_match($matcher, $key)) {
             $this->getEntry($key, [])->delete();
         }
     }
 }
Пример #2
0
 public function deleteMatched($matcher, array $options = [])
 {
     $allFiles = Toolbox\FileTools::searchFile($this->basePath);
     foreach ($allFiles as $file) {
         $key = urldecode(substr($file, strrpos($file, DIRECTORY_SEPARATOR) + 1));
         if (preg_match($matcher, $key)) {
             $this->getEntry($key, [])->delete();
         }
     }
     foreach (Toolbox\FileTools::listFilesRecursive($this->basePath) as $finfo) {
         $key = $finfo->getBaseName();
         $entry = $this->getEntry($key, []);
         if ($entry->expired()) {
             $entry->delete();
         }
     }
 }
Пример #3
0
 protected function compileOtherFiles()
 {
     $exts = $this->filePatterns;
     $pattern = '{' . implode(',', $exts) . '}';
     $foundFiles = [];
     foreach ($this->paths as $assetsRoot) {
         $foundFiles = array_merge($foundFiles, Rails\Toolbox\FileTools::searchFile($assetsRoot, $pattern, GLOB_BRACE));
     }
     $files = [];
     $assetsPath = $this->compilePath() . $this->prefix();
     foreach ($foundFiles as $foundFile) {
         $file = new File($foundFile);
         $contents = file_get_contents($foundFile);
         $this->createCompiledFile($assetsPath . '/' . $file->relative_path(), $contents, false);
         if ($this->config()->digest) {
             $md5 = md5_file($foundFile);
             $relativeDir = $file->relative_dir();
             if ($relativeDir) {
                 $relativeDir .= '/';
             }
             $relativePath = $relativeDir . $file->file_root();
             $basePath = $this->compilePath() . $this->prefix();
             $fileroot = $basePath . '/' . $relativeDir . $file->file_root();
             # Delete previous md5 files
             $pattern = $fileroot . '-*.' . $ext . '*';
             if ($mfiles = glob($pattern)) {
                 $regexp = '/-' . $md5 . '\\.' . $ext . '(\\.gz)?$/';
                 foreach ($mfiles as $mfile) {
                     if (!preg_match($regexp, $mfile)) {
                         unlink($mfile);
                     }
                 }
             }
             $this->updateManifestIndex($relativePath . '.' . $ext, $relativePath . '-' . $md5 . '.' . $ext);
             $md5File = $file->relative_file_root_path() . '-' . $md5 . '.' . $file->type();
             $this->createCompiledFile($assetsPath . '/' . $md5File, $contents, false);
         }
     }
 }