Skip to content

Commit

Permalink
Return filename found on FS when getting from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakambda committed Nov 29, 2024
1 parent 6b29767 commit 5eef9be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"require": {
"ext-dom": "*",
"ext-curl": "*",
"ext-libxml": "*"
"ext-libxml": "*",
"ext-fileinfo": "*"
}
}
11 changes: 5 additions & 6 deletions piccache.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,14 @@ public function store_in_cache(string $url): FetchHit
public function get_cached_data(string $url): CacheHit
{
$this->store_in_cache($url);
if (!$this->is_cached($url)) {
$cached = $this->is_cached($url);
if (!$cached) {
return new CacheHit();
}

$file_name = $this->get_filename($url);
$file_size = filesize($file_name);

$content_type = mime_content_type($file_name);
return new CacheHit(true, $file_name, $file_size, $content_type);
$file_size = filesize($cached);
$content_type = mime_content_type($cached);
return new CacheHit(true, $cached, $file_size, $content_type);
}

private function is_cached(string $url): ?string
Expand Down

0 comments on commit 5eef9be

Please sign in to comment.