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;