From a7df2bc4fb6c71d635ecd9762962c3ab91be7a6e Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 16 Mar 2021 17:18:11 +0100 Subject: [PATCH] Use original file when loading cover from file in album cover manager --- src/covermanager/albumcovermanager.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/covermanager/albumcovermanager.cpp b/src/covermanager/albumcovermanager.cpp index 6805e11a8..a7f0ee18b 100644 --- a/src/covermanager/albumcovermanager.cpp +++ b/src/covermanager/albumcovermanager.cpp @@ -778,11 +778,13 @@ void AlbumCoverManager::SearchForCover() { void AlbumCoverManager::SaveImageToAlbums(Song *song, const AlbumCoverImageResult &result) { - QUrl cover_url; + QUrl cover_url = result.cover_url; switch (album_cover_choice_controller_->get_save_album_cover_type()) { case CollectionSettingsPage::SaveCoverType_Cache: case CollectionSettingsPage::SaveCoverType_Album: - cover_url = album_cover_choice_controller_->SaveCoverToFileAutomatic(song, result); + if (cover_url.isEmpty() || !cover_url.isValid() || !cover_url.isLocalFile()) { + cover_url = album_cover_choice_controller_->SaveCoverToFileAutomatic(song, result); + } break; case CollectionSettingsPage::SaveCoverType_Embedded: cover_url = QUrl::fromLocalFile(Song::kEmbeddedCover); @@ -981,12 +983,12 @@ void AlbumCoverManager::SaveAndSetCover(AlbumItem *item, const AlbumCoverImageRe } else { QUrl cover_url; - if (!result.image_data.isNull() || !result.image.isNull()) { - cover_url = album_cover_choice_controller_->SaveCoverToFileAutomatic(Song::Source_Collection, albumartist, album, QString(), urls.first().adjusted(QUrl::RemoveFilename).path(), result, false); - } - else if (!result.cover_url.isEmpty() && !result.cover_url.isLocalFile()) { + if (!result.cover_url.isEmpty() && result.cover_url.isValid() && result.cover_url.isLocalFile()) { cover_url = result.cover_url; } + else if (!result.image_data.isEmpty() || !result.image.isNull()) { + cover_url = album_cover_choice_controller_->SaveCoverToFileAutomatic(Song::Source_Collection, albumartist, album, QString(), urls.first().adjusted(QUrl::RemoveFilename).path(), result, false); + } if (cover_url.isEmpty()) return;