Skip to content

Commit

Permalink
Catching an occasional error where ->get() on a cache file threw a Il…
Browse files Browse the repository at this point in the history
…luminate\Contracts\Filesystem\FileNotFoundException.
  • Loading branch information
Jon Baker committed Jun 29, 2016
1 parent 6931c15 commit 6e344e4
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/LaravelCacheGarbageCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,24 @@ public function handle()
continue;
}

// Grab the contents of the file
$contents = \Storage::disk('fcache')->get($cachefile);
try {
// Grab the contents of the file
$contents = \Storage::disk('fcache')->get($cachefile);

// Get the expiration time
$expire = substr($contents, 0, 10);
// Get the expiration time
$expire = substr($contents, 0, 10);

// See if we have expired
if(time() >= $expire) {
// Delete the file
\Storage::disk('fcache')->delete($cachefile);
$expired_file_count++;
} else {
$active_file_count++;
// See if we have expired
if(time() >= $expire) {
// Delete the file
\Storage::disk('fcache')->delete($cachefile);
$expired_file_count++;
} else {
$active_file_count++;
}
} catch(\Illuminate\Contracts\Filesystem\FileNotFoundException $e) {
// Getting an occasional error of this type on the 'get' command above,
// so adding a try-catch to skip the file if we do.
}
}

Expand Down

0 comments on commit 6e344e4

Please sign in to comment.