Delete stale optimized collection assets.

File

src/Asset/CssCollectionOptimizer.php, line 257

Class

CssCollectionOptimizer

Namespace

Drupal\advagg\Asset

Code

public function deleteStale() {
    $log = [];
    $this->state
        ->delete('system.css_cache_files');
    Cache::invalidateTags([
        'library_info',
    ]);
    $delete_stale = function ($uri) use (&$log) {
        // Default stale file threshold is 30 days.
        if (REQUEST_TIME - fileatime($uri) > $this->systemConfig
            ->get('stale_file_threshold')) {
            file_unmanaged_delete($uri);
            $log[] = $uri;
        }
    };
    file_scan_directory($this->dumper
        ->preparePath('css'), '/.*/', [
        'callback' => $delete_stale,
    ]);
    return $log;
}