Fix path+filename checking in database when comparing to filesystem contents

This commit is contained in:
Junior 2024-12-02 07:42:13 -05:00
parent 516bc6bfa9
commit eb04386d68

View File

@ -31,9 +31,10 @@ $query = "SELECT id, path, filename FROM books ORDER BY path, filename";
$sth = $globaldbh->prepare($query);
$sth->execute();
while ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
$dbbooks[] = $row['path'] . (($row['path'] != "/") ? "/" : "") . $row['filename'];
$dbbook = $row['path'] . (($row['path'] != "/") ? "/" : "") . $row['filename'];
$dbbooks[] = $dbbook;
}
$query = "DELETE FROM books WHERE CONCAT(path, filename)=:target";
$query = "DELETE FROM books WHERE CONCAT(path, filename)=:target OR CONCAT(path, '/', filename)=:target";
$sth = $globaldbh->prepare($query);
foreach ( $dbbooks as $dbbook ) {
if ( !is_file(BOOKDIR . $dbbook) ) {