Skip to content

Commit

Permalink
Fix cover art updating not always working correctly with PostgreSQL
Browse files Browse the repository at this point in the history
With PostgreSQL, uploading an image file caused an unhandled exception
Doctrine\DBAL\Exception\DriverException in case the target folder contained
songs of more than one album. Hence, the uploaded image wasn't immediately
used as a cover art for any album or artist. For album covers, the image was
pulled later by the background task but for artist cover, the file could be
detected only by running a new library scan.

The root cause was that the way used to handle the parameters of the SQL query
wasn't compatible with PgSQL.

refs owncloud#1164
  • Loading branch information
paulijar committed Aug 15, 2024
1 parent 7e29e5f commit 594a63c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Fixed
- Favorite toggle button not working on artists with no image available
- Cover art image not used automatically upon the image file upload in some cases when PostgreSQL used
[#1164](https://github.com/owncloud/music/issues/1164)

## 2.0.0 - 2024-06-23

Expand Down
5 changes: 3 additions & 2 deletions lib/Db/AlbumMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,11 @@ public function updateFolderCover(int $coverFileId, int $folderId) : bool {

$updated = false;
if ($result->rowCount()) {
$albumIds = $result->fetchAll(\PDO::FETCH_COLUMN);
$sql = 'UPDATE `*PREFIX*music_albums`
SET `cover_file_id` = ?
WHERE `cover_file_id` IS NULL AND `id` IN (?)';
$params = [$coverFileId, \join(",", $result->fetchAll(\PDO::FETCH_COLUMN))];
WHERE `cover_file_id` IS NULL AND `id` IN '. $this->questionMarks(\count($albumIds));
$params = \array_merge([$coverFileId], $albumIds);
$result = $this->execute($sql, $params);
$updated = $result->rowCount() > 0;
}
Expand Down

0 comments on commit 594a63c

Please sign in to comment.