From 638b05b1dbb6c3b94fe9a601ccc86241dfbf3fb2 Mon Sep 17 00:00:00 2001 From: Andres Moschini Date: Sun, 25 Jul 2021 14:21:22 -0300 Subject: [PATCH] fix: use absolute path in place of partial one and calibre internal directory Using the _calibre internal directory_ concatenated to the _relative path_ is not enough when there is more than a library. --- fetch.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/fetch.php b/fetch.php index 9929700be..5a00b3eba 100644 --- a/fetch.php +++ b/fetch.php @@ -3,7 +3,7 @@ * COPS (Calibre OPDS PHP Server) * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) - * @author Sébastien Lucas + * @author SĂ©bastien Lucas */ require_once dirname(__FILE__) . '/config.php'; @@ -98,7 +98,7 @@ header('Content-Type: ' . $data->getMimeType()); break; } - $file = $book->getFilePath($type, $idData, true); + $file = $book->getFilePath($type, $idData); if (!$viewOnly && $type == 'epub' && $config['cops_update_epub-metadata']) { $book->getUpdatedEpub($idData); return; @@ -111,16 +111,10 @@ header('Content-Disposition: attachment; filename="' . basename($file) . '"'); } - $dir = $config['calibre_internal_directory']; - if (empty($config['calibre_internal_directory'])) { - $dir = Base::getDbDirectory(); - } - if (empty($config['cops_x_accel_redirect'])) { - $filename = $dir . $file; - $fp = fopen($filename, 'rb'); - header('Content-Length: ' . filesize($filename)); + $fp = fopen($file, 'rb'); + header('Content-Length: ' . filesize($file)); fpassthru($fp); } else { - header($config['cops_x_accel_redirect'] . ': ' . $dir . $file); + header($config['cops_x_accel_redirect'] . ': ' . $file); }