From 834b3a2ab69c83b3bc151e98fcf530a55b5a1acb Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Mon, 23 Mar 2026 13:05:50 +0100 Subject: [PATCH] Remove all existing cover files for a game before writing a new one --- src/app.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index e290f04..12e5f7b 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -1462,15 +1462,15 @@ bool App::setCoverFromFile(Game *game, const QString &filePath) extension = QStringLiteral("jpg"); } + QDir coversDir(coversPath); + const QStringList existingCovers = coversDir.entryList({game->id() + QStringLiteral(".*")}, QDir::Files); + for (const QString &existing : existingCovers) { + coversDir.remove(existing); + } + QString destFileName = game->id() + QStringLiteral(".") + extension; QString destPath = coversPath + QStringLiteral("/") + destFileName; - // Remove existing cover if any - QFile destFile(destPath); - if (destFile.exists()) { - destFile.remove(); - } - // Copy file if (!sourceFile.copy(destPath)) { return false;